Files
openshell_controller/tests/sandbox-lifecycle-check.mjs
T

352 lines
45 KiB
JavaScript

import assert from 'node:assert/strict'
import { readFile, stat } from 'node:fs/promises'
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 vllmApplyRoutePath = path.join(root, 'app/api/inference/vllm/apply/route.ts')
const vllmRestartRoutePath = path.join(root, 'app/api/inference/vllm/restart/route.ts')
const inferenceEndpointUrlPath = path.join(root, 'app/lib/inferenceEndpointUrl.ts')
const inferenceRouteStorePath = path.join(root, 'app/lib/inferenceRouteStore.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 sandboxInferenceStorePath = path.join(root, 'app/lib/sandboxInferenceStore.ts')
const sandboxRestartRoutePath = path.join(root, 'app/api/sandbox/[sandboxId]/restart/route.ts')
const gatewayRepairRoutePath = path.join(root, 'app/api/openshell/gateway/repair/route.ts')
const sandboxPrivilegedFilesPath = path.join(root, 'app/lib/sandboxPrivilegedFiles.ts')
const versionedInstallerPath = path.join(root, 'install_versioned_nemoclaw_openshell.sh')
const hookPath = path.join(root, 'app/hooks/useSandboxInventory.ts')
const pagePath = path.join(root, 'app/page.tsx')
const configPanelPath = path.join(root, 'app/components/ConfigurationPanel.tsx')
const activityPanelPath = path.join(root, 'app/components/ActivityPanel.tsx')
const inferencePanelPath = path.join(root, 'app/components/InferenceEndpointPanel.tsx')
const sandboxInferencePanelPath = path.join(root, 'app/components/SandboxInferencePanel.tsx')
const sidebarPath = path.join(root, 'app/components/Sidebar.tsx')
const sandboxListPath = path.join(root, 'app/components/SandboxList.tsx')
const openClawLogoPath = path.join(root, 'public/sandbox-logos/openclaw.svg')
const hermesLogoPath = path.join(root, 'public/sandbox-logos/hermes.png')
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 vllmApplyRouteSource = await readFile(vllmApplyRoutePath, 'utf8')
const vllmRestartRouteSource = await readFile(vllmRestartRoutePath, 'utf8')
const inferenceEndpointUrlSource = await readFile(inferenceEndpointUrlPath, 'utf8')
const inferenceRouteStoreSource = await readFile(inferenceRouteStorePath, '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 sandboxInferenceStoreSource = await readFile(sandboxInferenceStorePath, 'utf8')
const sandboxRestartRouteSource = await readFile(sandboxRestartRoutePath, 'utf8')
const gatewayRepairRouteSource = await readFile(gatewayRepairRoutePath, 'utf8')
const sandboxPrivilegedFilesSource = await readFile(sandboxPrivilegedFilesPath, 'utf8')
const versionedInstallerSource = await readFile(versionedInstallerPath, 'utf8')
const hookSource = await readFile(hookPath, 'utf8')
const pageSource = await readFile(pagePath, 'utf8')
const configPanelSource = await readFile(configPanelPath, 'utf8')
const activityPanelSource = await readFile(activityPanelPath, 'utf8')
const inferencePanelSource = await readFile(inferencePanelPath, 'utf8')
const sandboxInferencePanelSource = await readFile(sandboxInferencePanelPath, 'utf8')
const sidebarSource = await readFile(sidebarPath, 'utf8')
const sandboxListSource = await readFile(sandboxListPath, 'utf8')
const openClawLogoStat = await stat(openClawLogoPath)
const hermesLogoStat = await stat(hermesLogoPath)
assert.match(
createRouteSource,
/const readiness = await waitForSandboxReady\(sandboxName, 90000, 2000\)/,
'blueprint create must poll authoritative readiness before returning success',
)
assert.match(
createRouteSource,
/readiness:\s*\{\s*attempts: readiness\.attempts,\s*elapsedMs: readiness\.elapsedMs,/,
'blueprint create response must expose readiness polling metadata',
)
assert.match(createRouteSource, /recordActivity/, 'sandbox create route must persist create progress to the activity log')
assert.match(createRouteSource, /async function recordCreateActivity/, 'sandbox create activity logging must be isolated behind a best-effort helper')
assert.match(createRouteSource, /activity-log:error/, 'sandbox create activity logging failures must be reported without failing creation')
assert.match(createRouteSource, /sandbox\.create\.start/, 'sandbox create route must record a durable start event before long-running work')
assert.match(createRouteSource, /sandbox\.create\.success/, 'sandbox create route must record a durable success event')
assert.match(createRouteSource, /sandbox\.create\.error/, 'sandbox create route must record durable failure events')
assert.ok(createRouteSource.indexOf('if (!blueprint)') < createRouteSource.indexOf('sandbox.create.start'), 'sandbox create route must validate required blueprint before recording a start event')
assert.match(createRouteSource, /sandbox\.create\.error[\s\S]*unknown blueprint/, 'unknown blueprint must be paired with a durable error event after a start event')
assert.match(pageSource, /<ActivityPanel \/>/, 'dashboard must surface the activity log so create progress remains visible after navigation')
assert.match(activityPanelSource, /sandbox creation/, 'activity panel copy must include sandbox creation progress events')
assert.match(createRouteSource, /"onboard",[\s\S]*"--non-interactive",[\s\S]*"--recreate-sandbox"/, 'blueprint create must use the Monday-era normal NemoClaw onboard flow')
assert.match(createRouteSource, /type NemoClawAgent = "openclaw" \| "hermes" \| "langchain-deepagents-code"/, 'blueprint create must model OpenClaw, Hermes, and Deep Agents Code NemoClaw agents')
assert.match(createRouteSource, /function nemoClawAgentForBlueprint\(blueprint: string\): NemoClawAgent/, 'blueprint create must map dashboard blueprints to NemoClaw agents')
assert.match(createRouteSource, /blueprint === "nemoclaw-hermes" \? "hermes" : "openclaw"/, 'Hermes blueprint must select the Hermes NemoClaw agent without changing the OpenClaw default')
assert.match(createRouteSource, /blueprint === "nemoclaw-deepagents-code"\) return "langchain-deepagents-code"/, 'Deep Agents Code blueprint must select the upstream NemoClaw agent id')
assert.match(createRouteSource, /agent === "openclaw" \? \[\] : \["--agent", agent\]/, 'non-default NemoClaw agent creation must pass --agent to NemoClaw')
assert.match(createRouteSource, /type CreateGpuMode = "none" \| "auto" \| "required"/, 'blueprint create must model explicit GPU passthrough modes')
assert.match(createRouteSource, /process\.env\.OPENSHELL_CONTROL_CREATE_GPU_MODE \|\| "none"/, 'sandbox create must default to no GPU passthrough unless requested')
assert.match(createRouteSource, /mode === "required"[\s\S]*return \["--gpu"\]/, 'NemoClaw create must pass --gpu when GPU passthrough is required')
assert.match(createRouteSource, /mode === "none"[\s\S]*return \["--no-gpu"\]/, 'NemoClaw create must pass --no-gpu by default to avoid CDI failures')
assert.match(createRouteSource, /openShellGpuArgs\(mode: CreateGpuMode\)/, 'OpenShell create paths must share GPU request handling')
assert.doesNotMatch(createRouteSource, /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, /id: "redeploy-image"/, 'create API must expose image redeploy as a sandbox creation path')
assert.match(createRouteSource, /label: "Quick Deploy New NemoClaw Sandbox"/, 'image redeploy must be labeled as the quick deploy default path')
assert.match(createRouteSource, /label: "Fresh NemoClaw Image"/, 'full rebuild path must be labeled as fresh image creation')
assert.match(createRouteSource, /id: "nemoclaw-hermes"/, 'create API must expose Hermes sandbox creation')
assert.match(createRouteSource, /label: "Fresh Hermes Sandbox"/, 'Hermes sandbox creation must be labeled clearly in the create API')
assert.match(createRouteSource, /source: "~\/NemoClaw\/agents\/hermes\/Dockerfile"/, 'Hermes sandbox creation must point at the upstream Hermes agent source')
assert.match(createRouteSource, /id: "nemoclaw-deepagents-code"/, 'create API must expose Deep Agents Code sandbox creation')
assert.match(createRouteSource, /source: "~\/NemoClaw\/agents\/langchain-deepagents-code\/manifest\.yaml"/, 'Deep Agents Code sandbox creation must point at the upstream agent manifest')
assert.match(createRouteSource, /findNemoClawRegistryEntry/, 'image redeploy must discover NemoClaw sandbox images across default and alternate-port registries')
assert.match(createRouteSource, /listOpenShellSandboxNames/, 'image redeploy must fall back to live OpenShell inventory when registry entries are stale')
assert.match(createRouteSource, /resolveSourcePodImage\(sourceSandboxName, sandboxName\)/, 'image redeploy must allow optional explicit source while defaulting automatically')
assert.match(createRouteSource, /"--from",\s*sourceImage/, 'image redeploy must pass the resolved image to openshell sandbox create')
assert.match(createRouteSource, /registryEntry\?\.imageTag\?\.trim\(\)/, 'image redeploy must resolve the source image from NemoClaw registry metadata')
assert.doesNotMatch(createRouteSource, /OPENSHELL_CLUSTER_CONTAINER|readPodImage|"kubectl"/, 'image redeploy must not depend on obsolete cluster containers or in-container kubectl')
assert.match(createRouteSource, /"--auto-providers"/, 'image redeploy must use OpenShell auto providers for provider-backed images')
assert.match(createRouteSource, /skippedNemoClawImageRedeployRegistration/, 'image redeploy must report that NemoClaw registry registration was deliberately skipped')
assert.match(createRouteSource, /lifecycle identity, workload provenance, and agent-specific state that only NemoClaw can issue safely/, 'image redeploy must explain why direct NemoClaw registry writes are unsafe')
assert.doesNotMatch(createRouteSource, /function registerNemoClawImageRedeploy|writeFileSync\(tempPath|renameSync\(tempPath/, 'image redeploy must not forge current NemoClaw registry entries by copying source-bound authority receipts')
assert.match(createRouteSource, /readyVerification\?: SandboxVerification/, 'ready-aware create command must carry the authoritative verification result')
assert.match(createRouteSource, /readyVerification: verification/, 'ready-aware create command must return the verification that proved readiness')
assert.match(createRouteSource, /createAttempt\.readyVerification\?\.verified[\s\S]*await waitForSandboxReady\(sandboxName, 90000, 2000\)/, 'image redeploy must reuse the ready-command verification instead of always polling readiness twice')
assert.match(createRouteSource, /const requestedMode = typeof raw\.mode === "string" \? raw\.mode : "vllm"/, 'blueprint create must default to vLLM experimental onboarding when the UI payload is absent')
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 = "build"/, 'blueprint create must use NemoClaw build provider only for nvapi-* NVIDIA API keys')
assert.match(createRouteSource, /NEMOCLAW_PROVIDER = "custom"/, 'blueprint create must support OpenAI-compatible endpoint onboarding')
assert.match(createRouteSource, /NEMOCLAW_ENDPOINT_URL = settings\.endpointUrl/, 'OpenAI-compatible onboarding must pass the NemoClaw endpoint URL')
assert.match(createRouteSource, /COMPATIBLE_API_KEY = apiKey \|\| "dummy"/, 'OpenAI-compatible onboarding must pass COMPATIBLE_API_KEY or a no-auth placeholder')
assert.match(createRouteSource, /NEMOCLAW_PROVIDER_KEY = env\.COMPATIBLE_API_KEY/, 'OpenAI-compatible onboarding must bridge the provider key without printing secrets')
assert.match(createRouteSource, /Hosted NVIDIA Build onboarding requires an nvapi-\*/, 'blueprint create must reject non-nvapi keys for the hosted NVIDIA build provider')
assert.match(versionedInstallerSource, /OPENSHELL_VERSION="\$\{OPENSHELL_VERSION:-v0\.0\.116\}"/, '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\.7\.1\}"/, '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')
assert.match(createRouteSource, /repairOpenClawExecApprovalsFile/, 'sandbox create may apply the narrow exec approvals symlink compatibility repair')
assert.match(createRouteSource, /execApprovalsRepair/, 'sandbox create response must report the narrow exec approvals compatibility repair')
assert.match(createRouteSource, /created && isOpenClawAgent \? await repairOpenClawExecApprovalsFile/, 'Hermes create must skip OpenClaw-only exec approvals repair')
assert.match(createRouteSource, /created && isOpenClawAgent \? await approveOpenClawDeviceRequests/, 'Hermes create must skip OpenClaw-only device approval')
assert.doesNotMatch(sandboxPrivilegedFilesSource, /openshell-openclaw-policy-|"policy", "set"|withoutReadOnlyOpenClaw/, 'OpenClaw repair must not mutate OpenShell filesystem policy')
assert.match(sandboxPrivilegedFilesSource, /plugins\.entries\.bonjour/, 'gateway config stabilization must disable the crashing Bonjour plugin')
assert.match(sandboxPrivilegedFilesSource, /sha256sum openclaw\.json > \.config-hash/, 'gateway config stabilization must refresh OpenClaw config hash')
assert.match(sandboxPrivilegedFilesSource, /openclaw gateway run/, 'gateway config stabilization must restart the OpenClaw gateway')
assert.match(sandboxPrivilegedFilesSource, /"workspace"/, 'workspace repair must target the OpenClaw workspace directory')
assert.match(sandboxPrivilegedFilesSource, /\/sandbox\/\.openclaw-data\/\$dir/, 'workspace repair must use the policy-writable OpenClaw data tree')
assert.match(sandboxPrivilegedFilesSource, /ln -sfn/, 'workspace repair must link the OpenClaw workspace path into writable storage')
assert.match(sandboxPrivilegedFilesSource, /"flows"/, 'workspace repair must include the stock NemoClaw flows symlink')
assert.match(sandboxPrivilegedFilesSource, /"plugin-runtime-deps"/, 'workspace repair must include the OpenClaw plugin runtime dependency directory')
assert.match(sandboxPrivilegedFilesSource, /"update-check\.json"/, 'workspace repair must include the stock NemoClaw update-check symlink')
assert.match(sandboxPrivilegedFilesSource, /exec-approvals\.json/, 'workspace repair must include exec approval state handling')
assert.match(sandboxPrivilegedFilesSource, /const mutableFiles = \[\s*"update-check\.json",\s*\]/, 'workspace repair must not leave exec approvals in the symlinked mutable files list for newer OpenClaw')
assert.match(sandboxPrivilegedFilesSource, /chmod 0600 \/sandbox\/\.openclaw\/exec-approvals\.json/, 'workspace repair must make exec approvals a real writable file for newer OpenClaw')
assert.match(sandboxPrivilegedFilesSource, /chown -R sandbox:sandbox \/sandbox\/\.openclaw-data/, 'workspace repair must restore stock NemoClaw ownership for OpenClaw data')
assert.match(sandboxPrivilegedFilesSource, /AGENTS\.md/, 'workspace repair note must document the AGENTS.md permission failure it prevents')
assert.match(sandboxPrivilegedFilesSource, /"agents"/, 'workspace repair must target the OpenClaw agent directory so sessions are writable through .openclaw-data')
assert.match(sandboxPrivilegedFilesSource, /"agents"[\s\S]*"workspace"[\s\S]*"memory"/, 'workspace repair must cover NemoClaw expected OpenClaw mutable symlink directories')
assert.match(sandboxPrivilegedFilesSource, /sessions\.json\.lock|session lock/, 'workspace repair note must document the sessions.json.lock permission failure it prevents')
assert.match(sandboxPrivilegedFilesSource, /bundled OpenClaw expects/, 'workspace repair note must document the dashboard reconciles to the bundled OpenClaw expectations')
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')
assert.match(hookSource, /requestIdRef = useRef\(0\)/, 'inventory refresh must guard against stale concurrent responses')
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, /wipePersistentSandboxState/, 'delete route must best-effort wipe NemoClaw persistent state before OpenShell deletion')
assert.match(deleteRouteSource, /\["sandbox", "exec", "-n", sandboxName, "--", "sh", "-lc", script\]/, 'persistent state wipe must run inside the target sandbox before deletion')
assert.match(deleteRouteSource, /workspace-\*/, 'persistent state wipe must include NemoClaw multi-agent workspace globs')
assert.match(pageSource, /JSON\.stringify\(\{ sandboxName, agent: sandbox\?\.agent \|\| 'openclaw' \}\)/, 'destroy workflow must pass the selected NemoClaw agent to delete state cleanup')
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')
assert.match(deleteRouteSource, /OPENSHELL_GATEWAY: process\.env\.OPENSHELL_GATEWAY\?\.trim\(\) \|\| undefined/, 'delete route must preserve an explicit gateway without forcing the legacy NemoClaw name')
assert.match(hostCommandsSource, /export function hostCommandEnv/, 'host commands must provide a shared environment for OpenShell child processes')
assert.match(hostCommandsSource, /XDG_CONFIG_HOME/, 'shared host command environment must preserve the OpenShell config home')
assert.match(hostCommandsSource, /export function openshellGatewayAddressEnv/, 'shared host command environment must expose gateway address override variables')
assert.match(hostCommandsSource, /OPENSHELL_GATEWAY_HOST/, 'shared host command environment must pass a configurable gateway host to child processes')
assert.match(hostCommandsSource, /OPENSHELL_GATEWAY_PORT/, 'shared host command environment must pass a configurable gateway port to child processes')
assert.match(hostCommandsSource, /OPENSHELL_GATEWAY_URL/, 'shared host command environment must pass or synthesize a gateway URL for child processes')
assert.match(hostCommandsSource, /gateway\.json/, 'shared host command environment must read gateway address config from the OpenShell config directory')
assert.match(hostCommandsSource, /config\.json/, 'shared host command environment must also support the general OpenShell config file')
assert.match(hostCommandsSource, /gatewayHost/, 'OpenShell gateway address config must support a top-level gatewayHost key')
assert.match(hostCommandsSource, /gateway\.host/, 'OpenShell gateway address config must support a nested gateway host key')
assert.match(createRouteSource, /const env: NodeJS\.ProcessEnv = hostCommandEnv\(\{[\s\S]*NEMOCLAW_SANDBOX_NAME: sandboxName[\s\S]*OPENSHELL_GATEWAY: process\.env\.OPENSHELL_GATEWAY\?\.trim\(\) \|\| undefined/, 'NemoClaw onboard must preserve an explicit gateway while allowing NemoClaw to select its port-qualified gateway')
assert.match(createRouteSource, /NEMOCLAW_AGENT: agent/, 'NemoClaw onboard must receive the selected dashboard agent')
assert.match(deleteRouteSource, /env: hostCommandEnv\(\{[\s\S]*OPENSHELL_GATEWAY: process\.env\.OPENSHELL_GATEWAY\?\.trim\(\) \|\| undefined/, 'delete route must pass the shared host command environment without forcing a gateway')
assert.match(deleteRouteSource, /waitForSandboxDeleted/, 'delete route must poll authoritative inventory until the sandbox is gone')
assert.doesNotMatch(deleteRouteSource, /cleanupNemoClawSandbox/, 'delete route must not run NemoClaw destroy cleanup after OpenShell deletion')
assert.doesNotMatch(deleteRouteSource, /isNemoClawSandboxNotRegistered/, 'delete route must not keep NemoClaw registry cleanup helpers')
assert.doesNotMatch(deleteRouteSource, /\[sandboxName, "destroy", "--yes"\]/, 'delete route must not call nemoclaw destroy because it can delete the gateway')
assert.doesNotMatch(deleteRouteSource, /Pruned NemoClaw registry entry without destroying the shared OpenShell gateway|cleanupGatewayAfterLastSandbox/, 'delete route must not include the later registry-prune rewrite')
assert.match(deleteRouteSource, /openShellAlreadyGone/, 'delete route must tolerate sandboxes that OpenShell already deleted while NemoClaw still has registry state')
assert.doesNotMatch(deleteRouteSource, /isGatewayRecoverable|recoverableGateway/, 'delete route must not include the later gateway-repair branching')
assert.match(telemetryRouteSource, /const names = parseOpenShellSandboxNames\(sandboxListStdout\)/, 'telemetry must derive inventory from OpenShell before consulting NemoClaw')
assert.match(telemetryRouteSource, /names\.length > 0[\s\S]*execNemoclaw\(\["status"\]\)[\s\S]*execNemoclaw\(\["list", "--json"\]\)/, 'telemetry must skip NemoClaw list/status when OpenShell reports zero live sandboxes and prefer nemoclaw list --json when sandboxes exist')
assert.match(telemetryRouteSource, /readNemoClawRegistry/, 'telemetry must read the NemoClaw registry for agent metadata')
assert.match(telemetryRouteSource, /resolveSandboxAgent/, 'telemetry must resolve OpenClaw versus Hermes agent metadata')
assert.match(telemetryRouteSource, /"nemoclaw\.ai\/agent": agent/, 'telemetry pod labels must include the selected NemoClaw agent')
assert.match(hookSource, /agent\?: string/, 'inventory items must carry optional agent metadata')
assert.match(hookSource, /agent: typeof sandbox\.agent === 'string' && sandbox\.agent \? sandbox\.agent : 'openclaw'/, 'inventory summary mapping must default older registry entries to OpenClaw')
assert.match(sandboxListSource, /function displaySandboxAgent\(agent\?: string\)/, 'sandbox list must render agent labels')
assert.match(sandboxListSource, /function SandboxTypeLogo\(\{ agent \}/, 'sandbox list must render per-agent sandbox logos')
assert.match(sandboxListSource, /const OPENCLAW_SANDBOX_LOGO = '\/sandbox-logos\/openclaw\.svg'/, 'OpenClaw sandboxes must use the local OpenClaw favicon asset')
assert.match(sandboxListSource, /const HERMES_SANDBOX_LOGO = '\/sandbox-logos\/hermes\.png'/, 'Hermes sandboxes must use the local Hermes favicon asset')
assert.match(sandboxListSource, /const logoSrc = isHermes \? HERMES_SANDBOX_LOGO : isOpenClaw \? OPENCLAW_SANDBOX_LOGO : null/, 'sandbox type logo must avoid misclassifying unknown agents as OpenClaw')
assert.ok(openClawLogoStat.size > 0, 'OpenClaw favicon asset must be vendored locally')
assert.ok(hermesLogoStat.size > 0, 'Hermes favicon asset must be vendored locally')
assert.match(sandboxListSource, /selectedSandbox\?\.agent === 'hermes'/, 'sandbox operations must detect Hermes sandboxes')
assert.match(sandboxListSource, /Connect to Hermes/, 'sandbox operations must show a Hermes connect action instead of an OpenClaw dashboard action')
assert.match(sandboxListSource, /launch: 'hermes'/, 'Hermes connect action must open the operator terminal in Hermes launch mode')
assert.match(sandboxListSource, /dashboardSessionId/, 'Hermes connect action must preserve the dashboard terminal session id')
assert.match(sandboxListSource, /DISMISSED_PERMISSION_ALERTS_STORAGE_KEY/, 'sandbox list must persist locally hidden permission alerts')
assert.match(sandboxListSource, /visiblePendingRequests\(feed, sandbox, dismissedPermissionAlerts\)/, 'sandbox permission dropdown must hide dismissed pending alerts')
assert.match(sandboxListSource, /<option value=\{DISMISS_PERMISSION_VALUE\}>Do Nothing<\/option>/, 'permission dropdown must offer a Do Nothing option')
assert.match(sandboxListSource, /dismissPermissionAlerts\(selectedSandbox, request\.chunkId\)/, 'sandbox policy drawer must support doing nothing for a specific permission request')
assert.match(inferenceRouteSource, /\["provider", "create", "--name", name, "--type", type\]/, 'inference route must create OpenShell providers')
assert.match(inferenceRouteSource, /\["provider", "update", name\]/, 'inference route must update existing OpenShell providers')
assert.match(inferenceRouteSource, /\["provider", "delete", name\]/, 'inference route must delete OpenShell providers')
assert.match(inferenceRouteSource, /\["inference", "set", "--provider", name, "--model", model\]/, 'inference route must set the active OpenShell inference route')
assert.match(inferenceRouteSource, /"vllm"/, 'inference route must accept the dashboard vLLM provider type')
assert.match(inferenceRouteSource, /type === "vllm"[\s\S]*\? "openai" : type/, 'inference route must store vLLM selections as OpenAI-compatible providers')
assert.match(inferenceRouteSource, /isVllmEndpoint\(name, baseUrl\)/, 'inference route must skip verification for vLLM-compatible endpoints')
assert.match(inferenceRouteSource, /normalizeProviderType\(requestedType, name, baseUrl\)/, 'inference route must force vLLM endpoints through the OpenAI-compatible provider type')
assert.match(inferenceRouteSource, /isOllamaEndpoint\(name, baseUrl\)/, 'inference route must detect local Ollama endpoints')
assert.match(inferenceRouteSource, /isVllmEndpoint\(name, baseUrl\) \|\| isOllamaEndpoint\(name, baseUrl\)/, 'inference route must force local Ollama endpoints through the OpenAI-compatible provider type')
assert.match(inferenceRouteSource, /body\?\.noVerify !== false \|\| requestedType === "vllm" \|\| isVllmEndpoint\(name, baseUrl\) \|\| isOllamaEndpoint\(name, baseUrl\)/, 'inference route must skip verification for vLLM selections and local Ollama endpoints')
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(inferenceRouteSource, /verifiedRoutes: await buildVerifiedRoutes\(gateway, system, providers\)/, 'inference route must expose a verified provider/model route catalog')
assert.match(inferenceRouteSource, /rememberVerifiedInferenceRoute/, 'inference route must remember successfully saved provider/model pairs')
assert.match(inferenceRouteSource, /listSandboxInferenceRoutes/, 'inference route must seed verified route choices from existing sandbox profiles')
assert.match(inferenceRouteStoreSource, /inference-routes\.json/, 'verified inference route store must persist dashboard-known route choices')
assert.match(inferenceRouteStoreSource, /mergeVerifiedInferenceRoutes/, 'verified inference route store must dedupe provider/model route choices')
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')
assert.doesNotMatch(inferencePanelSource, /NVIDIA Preset|useNvidiaInferencePreset|aws\/anthropic\/claude-opus-4-5/, 'settings UI must not expose NVIDIA-corp-specific inference presets')
assert.match(inferencePanelSource, /useVllmPreset/, 'settings UI must expose a vLLM endpoint preset')
assert.match(inferencePanelSource, /\{ value: "vllm", label: "vLLM" \}/, 'settings UI must expose vLLM as an explicit provider type')
assert.match(inferencePanelSource, /setType\("vllm"\)/, 'vLLM preset must select the explicit vLLM provider type')
assert.match(inferencePanelSource, /const isVllmEndpointSelected = type === "vllm"/, 'settings UI must only show advanced vLLM controls when the vLLM provider type is selected')
assert.match(inferencePanelSource, /host\.docker\.internal:8000\/v1/, 'vLLM preset must point at the host vLLM OpenAI-compatible endpoint')
assert.match(inferencePanelSource, /function isVllmEndpoint\(name: string, baseUrl: string\)/, 'settings UI must detect vLLM-compatible endpoint selections')
assert.match(inferencePanelSource, /vLLM Advanced Configuration/, 'settings UI must expose advanced vLLM launch tuning when vLLM is selected')
assert.match(inferencePanelSource, /\/api\/inference\/vllm\/apply/, 'vLLM advanced configuration must apply launch changes through the controller')
assert.match(inferencePanelSource, /\/api\/inference\/vllm\/restart/, 'vLLM advanced configuration must expose a restart action')
assert.match(inferencePanelSource, /--max-model-len/, 'vLLM advanced configuration must generate a max model length launch flag')
assert.match(inferencePanelSource, /--gpu-memory-utilization/, 'vLLM advanced configuration must generate a GPU memory utilization launch flag')
assert.match(inferencePanelSource, /--kv-cache-dtype/, 'vLLM advanced configuration must expose KV cache dtype tuning')
assert.match(inferencePanelSource, /--hf-overrides/, 'vLLM advanced configuration must generate HF overrides for long-context model config')
assert.match(inferencePanelSource, /rope_scaling/, 'vLLM advanced configuration must expose YaRN/RoPE scaling')
assert.match(inferencePanelSource, /max_position_embeddings/, 'vLLM advanced configuration must override max_position_embeddings for long-context kernels')
assert.match(inferencePanelSource, /YaRN\/RoPE scaling/, 'vLLM advanced configuration must let users toggle long-context scaling')
assert.match(inferencePanelSource, /VLLM_ALLOW_LONG_MAX_MODEL_LEN=1/, 'vLLM advanced configuration must include the long max model length safety override for extended contexts')
assert.match(inferencePanelSource, /--enable-auto-tool-choice/, 'vLLM advanced configuration must include the tool-choice launch flag')
assert.match(inferencePanelSource, /--tool-call-parser/, 'vLLM advanced configuration must include the tool-call parser launch flag')
assert.match(vllmApplyRouteSource, /\["rm", "-f", container\]/, 'vLLM apply route must remove the previous container before recreating it')
assert.match(vllmApplyRouteSource, /"run", "-d"/, 'vLLM apply route must launch a replacement vLLM container')
assert.match(vllmApplyRouteSource, /--hf-overrides/, 'vLLM apply route must pass long-context HF overrides to vLLM')
assert.match(vllmApplyRouteSource, /rope_scaling/, 'vLLM apply route must include YaRN/RoPE scaling when enabled')
assert.match(vllmApplyRouteSource, /max_position_embeddings/, 'vLLM apply route must expand max_position_embeddings with max model length')
assert.match(vllmApplyRouteSource, /VLLM_ALLOW_LONG_MAX_MODEL_LEN=1/, 'vLLM apply route must allow vLLM to start above the derived 32K model length')
assert.match(vllmApplyRouteSource, /execFileAsync\(DOCKER_BIN, runArgs/, 'vLLM apply route must execute Docker with argv instead of shell text')
assert.match(vllmRestartRouteSource, /\["restart", container\]/, 'vLLM restart route must restart the selected vLLM container with docker restart')
assert.match(vllmRestartRouteSource, /OPENSHELL_CONTROL_VLLM_CONTAINER/, 'vLLM restart route must support an explicit default container env var')
assert.match(vllmRestartRouteSource, /OPENSHELL_CONTROL_VLLM_CONTAINERS|VLLM_CONTAINER_ALLOWLIST/, 'vLLM restart route must support an explicit container allowlist')
assert.match(vllmRestartRouteSource, /\^vllm/, 'vLLM restart route must restrict generic restarts to vLLM-named containers')
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, /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:\/\/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')
assert.match(sandboxInferenceRouteSource, /const id = `\$\{provider\}::\$\{model\}`/, 'sandbox inference route must canonicalize route ids from provider/model pairs')
assert.match(sandboxInferenceStoreSource, /hasExplicitRoutes \? \[\] : legacyModels\.map/, 'sandbox inference store must not re-expand legacy provider/models when explicit routes are present')
assert.match(sandboxInferenceStoreSource, /const id = `\$\{provider\}::\$\{model\}`/, 'sandbox inference store must canonicalize route ids from provider/model pairs')
assert.match(sandboxInferencePanelSource, /Save Sandbox Routes/, 'selected sandbox UI must expose multi-route inference saving')
assert.match(sandboxInferencePanelSource, /Apply to Running Container/, 'selected sandbox UI must expose live apply for running containers')
assert.match(sandboxInferencePanelSource, /Verified Working Routes/, 'selected sandbox UI must list verified active inference routes')
assert.match(sandboxInferencePanelSource, /inferenceData\.verifiedRoutes/, 'selected sandbox UI must read the shared verified route catalog')
assert.match(sandboxInferencePanelSource, /inferenceData\.system/, 'selected sandbox UI must include system route status when available')
assert.doesNotMatch(sandboxInferencePanelSource, /Primary Route/, 'selected sandbox UI must not render a separate primary route summary box')
assert.match(sandboxInferencePanelSource, /Default/, 'selected sandbox UI must keep route selection while avoiding a separate primary route card')
assert.match(sandboxInferencePanelSource, /\/api\/sandbox\/\$\{encodeURIComponent\(sandbox\.id\)\}\/inference/, 'selected sandbox UI must load and save sandbox-specific inference profiles')
assert.match(sandboxInferencePanelSource, /\/api\/sandbox\/\$\{encodeURIComponent\(sandbox\.id\)\}\/inference\/apply/, 'selected sandbox UI must call live apply endpoint')
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(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, /spawn\(OPENSHELL_BIN, \["sandbox", "exec", "-n", sandboxName/, 'live apply must use the supported OpenShell sandbox exec boundary')
assert.match(sandboxInferenceApplyLibSource, /OPENSHELL_GATEWAY: process\.env\.OPENSHELL_GATEWAY\?\.trim\(\) \|\| undefined/, 'live apply must respect the active gateway unless explicitly configured')
assert.doesNotMatch(sandboxInferenceApplyLibSource, /docker[\s\S]*kubectl|OPENSHELL_CLUSTER_CONTAINER/, 'live apply must not depend on obsolete cluster containers or in-container kubectl')
assert.doesNotMatch(sandboxInferenceApplyLibSource, /chmod 444|chown root:root/, 'live apply must leave OpenClaw config writable by the sandbox owner for subsequent updates')
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(sandboxInferenceApplyLibSource, /resolveInferenceModelIdentity/, 'live apply must normalize provider/model identities for OpenClaw inference routes')
assert.match(sandboxInferenceApplyLibSource, /providerKey: "nvidia"[\s\S]*modelRef: route\.model/, 'live apply must preserve nvidia/... model refs without wrapping them as inference/...')
assert.doesNotMatch(sandboxRestartRouteSource, /delete", "pod"|kubectl delete/, 'restart route must not delete the backing sandbox pod')
assert.match(sandboxRestartRouteSource, /restartMode: "openclaw-runtime"/, 'restart route must restart only the in-sandbox OpenClaw runtime')
assert.match(sandboxRestartRouteSource, /waitForSandboxReady\(sandboxName, 15000, 1000\)/, 'restart route must verify OpenShell reports the sandbox ready before runtime restart')
assert.match(sandboxListSource, /Restart Sandbox/, 'sandbox details must expose the Monday-era sandbox restart button')
assert.match(sandboxListSource, /\/api\/sandbox\/\$\{encodeURIComponent\(selectedSandbox\.id\)\}\/restart/, 'restart button must call the sandbox restart endpoint')
assert.match(gatewayRepairRouteSource, /GATEWAY_LIFECYCLE_EXTERNAL/, 'obsolete gateway repair route must fail closed with a stable compatibility code')
assert.match(gatewayRepairRouteSource, /current OpenShell releases do not expose `openshell gateway start`/, 'gateway repair route must explain the removed OpenShell command')
assert.match(gatewayRepairRouteSource, /nemoclaw onboard/, 'gateway repair route must direct NemoClaw-owned gateways to the supported lifecycle owner')
assert.match(gatewayRepairRouteSource, /openshell gateway select <gateway>/, 'gateway repair route must retain safe external-gateway selection guidance')
assert.match(gatewayRepairRouteSource, /status: 409/, 'obsolete gateway repair must return a conflict instead of reporting a false repair')
assert.doesNotMatch(gatewayRepairRouteSource, /backupOpenShellConfig|gateway", "start"|\["sandbox", "list"\]/, 'obsolete gateway repair must not mutate config or invoke removed lifecycle commands')
assert.doesNotMatch(pageSource, /Repair Gateway Trust|api\/openshell\/gateway\/repair|It does not destroy sandboxes/, 'dashboard page must not include the later gateway trust repair UI after rollback')
assert.match(sandboxListSource, /setInterval\(loadPermissionFeeds/, 'sandbox list must match the Monday-era permission feed polling behavior')
assert.match(sandboxListSource, /<SandboxInferencePanel sandbox=\{selectedSandbox\}/, 'sandbox list must render the per-sandbox inference profile panel for the selected sandbox')
assert.match(sidebarSource, />Inference</, 'sidebar settings item must expose inference settings')
assert.match(pageSource, /<InferenceEndpointPanel \/>/, 'settings view must render inference endpoint panel')
assert.match(pageSource, /fetch\('\/api\/sandbox\/delete'/, 'destroy workflow must call the real sandbox delete endpoint')
assert.match(pageSource, /refresh\(\{ force: true \}\)/, 'create and destroy workflows must force fresh inventory reads')
assert.match(pageSource, /refreshUntilSandboxVisible/, 'create workflow must wait for the new sandbox to appear in inventory')
assert.match(pageSource, /refreshUntilSandboxGone/, 'destroy workflow must wait for deleted sandboxes to leave inventory')
assert.match(
pageSource,
/isDestroyMode \? \([\s\S]*<SandboxList[\s\S]*isDestroyMode=\{isDestroyMode\}/,
'destroy mode must render the sandbox list so a sandbox can be selected'
)
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, /NVIDIA hosted API/, 'create panel must expose hosted NVIDIA API onboarding')
assert.match(configPanelSource, /OpenAI-compatible endpoint/, 'create panel must expose custom OpenAI-compatible endpoint onboarding')
assert.match(configPanelSource, /createInferenceEndpointUrl/, 'create panel must send NEMOCLAW_ENDPOINT_URL for compatible endpoint onboarding')
assert.match(configPanelSource, /type CreateGpuMode = "none" \| "auto" \| "required"/, 'create panel must expose explicit GPU passthrough modes')
assert.match(configPanelSource, /gpuMode: createGpuMode/, 'create panel must send the selected GPU mode to the create API')
assert.match(configPanelSource, /Require GPU/, 'create panel must let operators require GPU passthrough')
assert.match(configPanelSource, /createInference/, 'create panel must send create-time inference settings')
assert.match(configPanelSource, /selectedBlueprint === 'nemoclaw-blueprint' \|\| selectedBlueprint === 'nemoclaw-hermes' \|\| selectedBlueprint === 'nemoclaw-deepagents-code'/, 'create panel must treat NemoClaw managed agents as onboard blueprints')
assert.match(configPanelSource, /selectedBlueprint === 'nemoclaw-hermes' \? 'my-hermes'/, 'create panel must provide a Hermes-specific sandbox name placeholder')
assert.match(configPanelSource, /selectedBlueprint === 'nemoclaw-deepagents-code' \? 'my-deepagents-code'/, 'create panel must provide a Deep Agents Code-specific sandbox name placeholder')
assert.match(configPanelSource, /useState<string>\('redeploy-image'\)/, 'create panel must default to quick deploy')
assert.doesNotMatch(configPanelSource, /Source Sandbox|sourceSandboxName/, 'basic create panel must not require choosing a source image')
console.log('sandbox-lifecycle-check: PASS create/destroy lifecycle assertions')