From 9a57ee6ad2208157884f0aa896365a0132ec81fd Mon Sep 17 00:00:00 2001 From: mmckeen-nv <108093260+mmckeen-nv@users.noreply.github.com> Date: Tue, 30 Jun 2026 00:10:05 -0600 Subject: [PATCH] chore: sync NemoClaw provider onboarding Sync create-time NemoClaw provider onboarding with upstream custom endpoint and hosted NVIDIA credential contracts. --- README.md | 3 +- app/api/sandbox/create/route.ts | 55 +++++++++++++++++++++++++-- app/components/ConfigurationPanel.tsx | 30 ++++++++++----- tests/sandbox-lifecycle-check.mjs | 12 ++++-- 4 files changed, 83 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index e2c05d9..f28ef31 100644 --- a/README.md +++ b/README.md @@ -258,7 +258,8 @@ The UI supports per-sandbox route profiles and can apply them live to OpenClaw w Supported provider categories in the UI: - Ollama -- NVIDIA NIM +- NVIDIA hosted API with `nvapi-*` credentials through NemoClaw's `build` provider +- OpenAI-compatible NVIDIA/enterprise inference endpoints through NemoClaw's `custom` provider with `NEMOCLAW_ENDPOINT_URL`, `COMPATIBLE_API_KEY`, and `NEMOCLAW_PROVIDER_KEY` - vLLM - external HTTP-compatible endpoints diff --git a/app/api/sandbox/create/route.ts b/app/api/sandbox/create/route.ts index c99de7a..0a1d340 100644 --- a/app/api/sandbox/create/route.ts +++ b/app/api/sandbox/create/route.ts @@ -75,13 +75,14 @@ type NemoClawCreateCommand = { mode: "cli-onboard" | "legacy-setup" } -type CreateInferenceMode = "auto" | "vllm" | "nim" +type CreateInferenceMode = "auto" | "vllm" | "nvidia" | "compatible" | "nim" type CreateGpuMode = "none" | "auto" | "required" type NemoClawAgent = "openclaw" | "hermes" | "langchain-deepagents-code" type CreateInferenceSettings = { mode: CreateInferenceMode model: string + endpointUrl: string hasApiKey: boolean envSummary: string[] } @@ -101,21 +102,45 @@ function parseCreateGpuMode(body: any): CreateGpuMode { function parseCreateInferenceSettings(body: any): CreateInferenceSettings { const raw = body?.createInference && typeof body.createInference === "object" ? body.createInference : {} const requestedMode = typeof raw.mode === "string" ? raw.mode : "vllm" - const mode: CreateInferenceMode = requestedMode === "vllm" || requestedMode === "nim" ? requestedMode : "auto" + const mode: CreateInferenceMode = requestedMode === "vllm" || requestedMode === "nvidia" || requestedMode === "compatible" || requestedMode === "nim" ? requestedMode : "auto" const model = typeof raw.model === "string" ? raw.model.trim() : "" + const endpointUrl = typeof raw.endpointUrl === "string" ? raw.endpointUrl.trim() : "" const apiKey = typeof raw.apiKey === "string" ? raw.apiKey.trim() : "" return { - mode, + mode: mode === "nim" ? "nvidia" : mode, model, + endpointUrl, hasApiKey: Boolean(apiKey), envSummary: [], } } +function isNvapiKey(apiKey: string) { + return /^nvapi-/i.test(apiKey) +} + +function applyCompatibleEndpointEnv(env: NodeJS.ProcessEnv, settings: CreateInferenceSettings, apiKey: string) { + if (!settings.endpointUrl) { + throw new Error("OpenAI-compatible NemoClaw onboarding requires an endpoint URL (NEMOCLAW_ENDPOINT_URL).") + } + env.NEMOCLAW_PROVIDER = "custom" + env.NEMOCLAW_ENDPOINT_URL = settings.endpointUrl + env.COMPATIBLE_API_KEY = apiKey || "dummy" + env.NEMOCLAW_PROVIDER_KEY = env.COMPATIBLE_API_KEY + settings.envSummary.push( + "NEMOCLAW_PROVIDER=custom", + "NEMOCLAW_ENDPOINT_URL=", + apiKey ? "COMPATIBLE_API_KEY=" : "COMPATIBLE_API_KEY=", + apiKey ? "NEMOCLAW_PROVIDER_KEY=" : "NEMOCLAW_PROVIDER_KEY=", + ) +} + function applyCreateInferenceEnv(env: NodeJS.ProcessEnv, settings: CreateInferenceSettings, body: any) { if (settings.mode === "auto") return settings + const apiKey = typeof body?.createInference?.apiKey === "string" ? body.createInference.apiKey.trim() : "" + env.NEMOCLAW_EXPERIMENTAL = "1" settings.envSummary.push("NEMOCLAW_EXPERIMENTAL=1") @@ -124,10 +149,32 @@ function applyCreateInferenceEnv(env: NodeJS.ProcessEnv, settings: CreateInferen settings.envSummary.push("NEMOCLAW_PROVIDER=vllm") } + if (settings.mode === "nvidia") { + if (apiKey && !isNvapiKey(apiKey)) { + if (settings.endpointUrl) { + applyCompatibleEndpointEnv(env, settings, apiKey) + } else { + throw new Error("Hosted NVIDIA Build onboarding requires an nvapi-* NVIDIA API key. For OpenAI-compatible NVIDIA inference keys, select the OpenAI-compatible endpoint mode and provide NEMOCLAW_ENDPOINT_URL.") + } + } else { + env.NEMOCLAW_PROVIDER = "build" + settings.envSummary.push("NEMOCLAW_PROVIDER=build") + if (apiKey) { + env.NVIDIA_INFERENCE_API_KEY = apiKey + env.NVIDIA_API_KEY = apiKey + env.NEMOCLAW_PROVIDER_KEY = apiKey + settings.envSummary.push("NVIDIA_INFERENCE_API_KEY=", "NVIDIA_API_KEY=", "NEMOCLAW_PROVIDER_KEY=") + } + } + } + + if (settings.mode === "compatible") { + applyCompatibleEndpointEnv(env, settings, apiKey) + } + 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_INFERENCE_API_KEY = apiKey env.NVIDIA_API_KEY = apiKey diff --git a/app/components/ConfigurationPanel.tsx b/app/components/ConfigurationPanel.tsx index 01275e3..2d1f957 100644 --- a/app/components/ConfigurationPanel.tsx +++ b/app/components/ConfigurationPanel.tsx @@ -7,7 +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" +type CreateInferenceMode = "auto" | "vllm" | "nvidia" | "compatible" type CreateGpuMode = "none" | "auto" | "required" interface NetworkRule { method: string; path: string } @@ -92,6 +92,7 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre const [createGpuMode, setCreateGpuMode] = useState("none") const [createInferenceMode, setCreateInferenceMode] = useState("vllm") const [createInferenceModel, setCreateInferenceModel] = useState("") + const [createInferenceEndpointUrl, setCreateInferenceEndpointUrl] = useState("") const [createNvidiaApiKey, setCreateNvidiaApiKey] = useState("") const [restoreFromBackup, setRestoreFromBackup] = useState(false) const [restoreArchive, setRestoreArchive] = useState(null) @@ -144,7 +145,8 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre const createInference = { mode: createInferenceMode, model: createInferenceModel.trim(), - apiKey: createInferenceMode === 'nim' ? createNvidiaApiKey.trim() : '', + endpointUrl: createInferenceEndpointUrl.trim(), + apiKey: (createInferenceMode === 'nvidia' || createInferenceMode === 'compatible') ? 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, gpuMode: createGpuMode, createInference, policy: assembledPolicy, preset: selectedPreset || null }) }) const data = await res.json() @@ -257,7 +259,7 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre
Inference at Create

Choose the provider NemoClaw should use while onboarding this sandbox.

-
+
-
{createInferenceMode !== 'auto' && ( @@ -277,10 +283,16 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre 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' && ( + {createInferenceMode === 'compatible' && (
- - 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)]" /> + + setCreateInferenceEndpointUrl(e.target.value)} placeholder="https://integrate.api.nvidia.com/v1" 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 === 'nvidia' || createInferenceMode === 'compatible') && ( +
+ + setCreateNvidiaApiKey(e.target.value)} placeholder={createInferenceMode === 'nvidia' ? 'nvapi-...' : 'endpoint token or blank for no auth'} 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)]" />
)} diff --git a/tests/sandbox-lifecycle-check.mjs b/tests/sandbox-lifecycle-check.mjs index 8ec8bfc..0cd3cbc 100644 --- a/tests/sandbox-lifecycle-check.mjs +++ b/tests/sandbox-lifecycle-check.mjs @@ -114,8 +114,12 @@ assert.match(createRouteSource, /createAttempt\.readyVerification\?\.verified[\s 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 = "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(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\.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\.27\}"/, 'versioned installer must pin the current NemoClaw-compatible OpenClaw base image version') @@ -320,7 +324,9 @@ assert.match( assert.doesNotMatch(pageSource, /console\.log\('Destroying sandbox:'/, 'destroy workflow must not be a UI-only placeholder') assert.doesNotMatch(configPanelSource, /onInventoryRefresh/, 'create panel must leave post-create inventory orchestration to the parent') assert.match(configPanelSource, /Use vLLM in experimental mode/, 'create panel must expose vLLM experimental onboarding') -assert.match(configPanelSource, /Use NVIDIA NIM/, 'create panel must expose NVIDIA NIM onboarding') +assert.match(configPanelSource, /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')