From 443eba4ae1ed73637ed74ef28bdc34b2ac73f59c Mon Sep 17 00:00:00 2001 From: mmckeen-nv Date: Thu, 30 Apr 2026 10:13:23 -0700 Subject: [PATCH] Restore create-time inference selection --- app/api/sandbox/create/route.ts | 61 +++++++++++++++++++- app/components/ConfigurationPanel.tsx | 82 ++++++++++++++++++++++++++- tests/sandbox-lifecycle-check.mjs | 9 ++- 3 files changed, 147 insertions(+), 5 deletions(-) diff --git a/app/api/sandbox/create/route.ts b/app/api/sandbox/create/route.ts index 1d1fbbf..c44b723 100644 --- a/app/api/sandbox/create/route.ts +++ b/app/api/sandbox/create/route.ts @@ -57,6 +57,60 @@ type NemoClawCreateCommand = { mode: "cli-onboard" | "legacy-setup" } +type CreateInferenceMode = "auto" | "vllm" | "nim" + +type CreateInferenceSettings = { + mode: CreateInferenceMode + model: string + hasApiKey: boolean + envSummary: string[] +} + +function parseCreateInferenceSettings(body: any): CreateInferenceSettings { + const raw = body?.createInference && typeof body.createInference === "object" ? body.createInference : {} + const requestedMode = typeof raw.mode === "string" ? raw.mode : "auto" + const mode: CreateInferenceMode = requestedMode === "vllm" || requestedMode === "nim" ? requestedMode : "auto" + const model = typeof raw.model === "string" ? raw.model.trim() : "" + const apiKey = typeof raw.apiKey === "string" ? raw.apiKey.trim() : "" + + return { + mode, + model, + hasApiKey: Boolean(apiKey), + envSummary: [], + } +} + +function applyCreateInferenceEnv(env: NodeJS.ProcessEnv, settings: CreateInferenceSettings, body: any) { + if (settings.mode === "auto") return settings + + env.NEMOCLAW_EXPERIMENTAL = "1" + settings.envSummary.push("NEMOCLAW_EXPERIMENTAL=1") + + if (settings.mode === "vllm") { + env.NEMOCLAW_PROVIDER = "vllm" + settings.envSummary.push("NEMOCLAW_PROVIDER=vllm") + } + + if (settings.mode === "nim") { + env.NEMOCLAW_PROVIDER = "nim-local" + settings.envSummary.push("NEMOCLAW_PROVIDER=nim-local") + const apiKey = typeof body?.createInference?.apiKey === "string" ? body.createInference.apiKey.trim() : "" + if (apiKey) { + env.NVIDIA_API_KEY = apiKey + env.NEMOCLAW_PROVIDER_KEY = apiKey + settings.envSummary.push("NVIDIA_API_KEY=", "NEMOCLAW_PROVIDER_KEY=") + } + } + + if (settings.model) { + env.NEMOCLAW_MODEL = settings.model + settings.envSummary.push(`NEMOCLAW_MODEL=${settings.model}`) + } + + return settings +} + function buildNemoClawCreateCommand(): NemoClawCreateCommand { if (NEMOCLAW_BIN && commandExists(NEMOCLAW_BIN)) { const args = ["onboard", "--non-interactive", "--recreate-sandbox", "--yes-i-accept-third-party-software"] @@ -331,7 +385,8 @@ export async function POST(request: Request) { const sandboxName = validateSandboxName(typeof body?.sandboxName === "string" ? body.sandboxName.trim() : "") const policy = body?.policy && typeof body.policy === "object" ? body.policy : null const enableTailscale = Boolean(body?.enableTailscale) - console.log(`[sandbox/create] request:parsed sandbox=${sandboxName} blueprint=${blueprint} enableTailscale=${enableTailscale} elapsedMs=${elapsedMs(requestStartedAt)}`) + const createInference = parseCreateInferenceSettings(body) + console.log(`[sandbox/create] request:parsed sandbox=${sandboxName} blueprint=${blueprint} enableTailscale=${enableTailscale} inferenceMode=${createInference.mode} elapsedMs=${elapsedMs(requestStartedAt)}`) if (!blueprint) { return NextResponse.json({ ok: false, error: "blueprint is required" }, { status: 400 }) @@ -353,6 +408,8 @@ export async function POST(request: Request) { env.NVIDIA_API_KEY = env.NVIDIA_API_KEY || "optional-local-mode" } + applyCreateInferenceEnv(env, createInference, body) + const result = await runCommand( createCommand.file, createCommand.mode === "legacy-setup" ? [...createCommand.args, sandboxName] : createCommand.args, @@ -369,6 +426,7 @@ export async function POST(request: Request) { blueprint, sandboxName, enableTailscale, + createInference, }, { status: 500 }) } @@ -393,6 +451,7 @@ export async function POST(request: Request) { verification, mode: "nemoclaw-blueprint", enableTailscale, + createInference, createCommand, hostPath: HOST_PATH, readiness: { diff --git a/app/components/ConfigurationPanel.tsx b/app/components/ConfigurationPanel.tsx index 731f380..eec1e1e 100644 --- a/app/components/ConfigurationPanel.tsx +++ b/app/components/ConfigurationPanel.tsx @@ -7,6 +7,7 @@ type EndpointProtocol = "" | "rest" type EndpointTls = "" | "terminate" | "passthrough" type EndpointEnforcement = "" | "enforce" | "audit" type EndpointAccess = "" | "read-only" | "read-write" | "full" +type CreateInferenceMode = "auto" | "vllm" | "nim" interface NetworkRule { method: string; path: string } interface NetworkEndpoint { host: string; port: string; protocol: EndpointProtocol; tls: EndpointTls; enforcement: EndpointEnforcement; access: EndpointAccess; rules: NetworkRule[] } @@ -87,6 +88,9 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre const [selectedBlueprint, setSelectedBlueprint] = useState('nemoclaw-blueprint') const [sandboxName, setSandboxName] = useState('') const [enableTailscale, setEnableTailscale] = useState(false) + const [createInferenceMode, setCreateInferenceMode] = useState("vllm") + const [createInferenceModel, setCreateInferenceModel] = useState("") + const [createNvidiaApiKey, setCreateNvidiaApiKey] = useState("") const [restoreFromBackup, setRestoreFromBackup] = useState(false) const [restoreArchive, setRestoreArchive] = useState(null) const [restorePath, setRestorePath] = useState('/sandbox') @@ -134,7 +138,12 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre if (mode === 'create') { if (!sandboxName.trim()) throw new Error('sandbox name is required') if (restoreFromBackup && !restoreArchive) throw new Error('backup archive is required when restore from backup is enabled') - const res = await fetch('/api/sandbox/create', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ blueprint: selectedBlueprint, sandboxName: sandboxName.trim(), enableTailscale, policy: assembledPolicy, preset: selectedPreset || null }) }) + const createInference = { + mode: createInferenceMode, + model: createInferenceModel.trim(), + apiKey: createInferenceMode === 'nim' ? createNvidiaApiKey.trim() : '', + } + const res = await fetch('/api/sandbox/create', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ blueprint: selectedBlueprint, sandboxName: sandboxName.trim(), enableTailscale, createInference, policy: assembledPolicy, preset: selectedPreset || null }) }) const data = await res.json() if (!res.ok) throw new Error([data.error, data.verification?.summary, data.verification?.error, data.stdout, data.stderr].filter(Boolean).join('\n\n')) const createdSandboxId = data.verification?.details?.id || data.verification?.details?.name || data.sandboxName @@ -188,7 +197,76 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre )} {loading ?
Loading policy…
:
- {mode === 'create' &&
Create Sandbox

Choose a template and enter a sandbox name.

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

Choose a template and enter a sandbox name.

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

Choose the provider NemoClaw should use while onboarding this sandbox.

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

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

{activePreset &&
{activePreset.label}

{activePreset.summary}

}
Filesystem Policy
Static
setPolicy({ ...policy, filesystem_policy: { ...policy.filesystem_policy, read_only: v } })} placeholder="/usr\n/lib\n/etc" /> setPolicy({ ...policy, filesystem_policy: { ...policy.filesystem_policy, read_write: v } })} placeholder="/sandbox\n/tmp" />
Network Policies
Dynamic
diff --git a/tests/sandbox-lifecycle-check.mjs b/tests/sandbox-lifecycle-check.mjs index 818ae37..2576a8a 100644 --- a/tests/sandbox-lifecycle-check.mjs +++ b/tests/sandbox-lifecycle-check.mjs @@ -62,7 +62,10 @@ assert.match( assert.match(createRouteSource, /"onboard", "--non-interactive", "--recreate-sandbox"/, 'blueprint create must use the Monday-era normal NemoClaw onboard flow') assert.doesNotMatch(createRouteSource, /"--from"|resolvePreferredNemoClawDockerfile|prepareDashboardOwnedNemoClawDockerfile/, 'blueprint create must not force the explicit Dockerfile path') assert.match(createRouteSource, /NEMOCLAW_SANDBOX_NAME: sandboxName/, 'blueprint create must pass the requested sandbox name to NemoClaw onboarding') -assert.doesNotMatch(createRouteSource, /NEMOCLAW_EXPERIMENTAL|NEMOCLAW_PROVIDER|NEMOCLAW_PROVIDER_KEY/, 'blueprint create must stay on the Monday-era stock NemoClaw onboarding path') +assert.match(createRouteSource, /NEMOCLAW_EXPERIMENTAL = "1"/, 'blueprint create must support NemoClaw experimental provider onboarding') +assert.match(createRouteSource, /NEMOCLAW_PROVIDER = "vllm"/, 'blueprint create must support the vLLM onboarding provider') +assert.match(createRouteSource, /NEMOCLAW_PROVIDER = "nim-local"/, 'blueprint create must support the NVIDIA NIM onboarding provider') +assert.match(createRouteSource, /NEMOCLAW_PROVIDER_KEY = apiKey/, 'blueprint create must pass NVIDIA API keys through provider env without changing NemoClaw') assert.match(versionedInstallerSource, /OPENCLAW_VERSION="\$\{OPENCLAW_VERSION:-2026\.4\.24\}"/, 'versioned installer must pin the dashboard-compatible NemoClaw OpenClaw version') 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') @@ -172,6 +175,8 @@ assert.match( ) assert.doesNotMatch(pageSource, /console\.log\('Destroying sandbox:'/, 'destroy workflow must not be a UI-only placeholder') assert.doesNotMatch(configPanelSource, /onInventoryRefresh/, 'create panel must leave post-create inventory orchestration to the parent') -assert.doesNotMatch(configPanelSource, /Use vLLM in experimental mode|Use NVIDIA NIM|createInference/, 'create panel must not include later create-time inference controls after rollback') +assert.match(configPanelSource, /Use vLLM in experimental mode/, 'create panel must expose vLLM experimental onboarding') +assert.match(configPanelSource, /Use NVIDIA NIM/, 'create panel must expose NVIDIA NIM onboarding') +assert.match(configPanelSource, /createInference/, 'create panel must send create-time inference settings') console.log('sandbox-lifecycle-check: PASS create/destroy lifecycle assertions')