chore: sync NemoClaw provider onboarding

Sync create-time NemoClaw provider onboarding with upstream custom endpoint and hosted NVIDIA credential contracts.
This commit is contained in:
mmckeen-nv
2026-06-30 00:10:05 -06:00
committed by GitHub
parent 1b5752793c
commit 9a57ee6ad2
4 changed files with 83 additions and 17 deletions
+51 -4
View File
@@ -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=<provided>",
apiKey ? "COMPATIBLE_API_KEY=<provided>" : "COMPATIBLE_API_KEY=<dummy-no-auth>",
apiKey ? "NEMOCLAW_PROVIDER_KEY=<provided>" : "NEMOCLAW_PROVIDER_KEY=<dummy-no-auth>",
)
}
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=<provided>", "NVIDIA_API_KEY=<legacy-alias>", "NEMOCLAW_PROVIDER_KEY=<provided>")
}
}
}
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
+21 -9
View File
@@ -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<CreateGpuMode>("none")
const [createInferenceMode, setCreateInferenceMode] = useState<CreateInferenceMode>("vllm")
const [createInferenceModel, setCreateInferenceModel] = useState<string>("")
const [createInferenceEndpointUrl, setCreateInferenceEndpointUrl] = useState<string>("")
const [createNvidiaApiKey, setCreateNvidiaApiKey] = useState<string>("")
const [restoreFromBackup, setRestoreFromBackup] = useState<boolean>(false)
const [restoreArchive, setRestoreArchive] = useState<File | null>(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
<h6 className="text-xs font-semibold uppercase tracking-wider text-[var(--foreground)]">Inference at Create</h6>
<p className="mt-1 text-xs text-[var(--foreground-dim)]">Choose the provider NemoClaw should use while onboarding this sandbox.</p>
</div>
<div className="grid grid-cols-1 gap-3 md:grid-cols-3">
<div className="grid grid-cols-1 gap-3 md:grid-cols-4">
<label className={`flex items-start gap-3 rounded-sm border p-3 text-sm text-[var(--foreground)] ${createInferenceMode === 'auto' ? 'border-[var(--nvidia-green)] bg-[rgba(118,185,0,0.08)]' : 'border-[var(--border-subtle)] bg-[var(--background-tertiary)]'}`}>
<input type="checkbox" checked={createInferenceMode === 'auto'} onChange={() => setCreateInferenceMode('auto')} className="mt-0.5 h-4 w-4 accent-[var(--nvidia-green)]" />
<span><span className="block text-xs font-mono uppercase tracking-wider">Auto</span><span className="mt-1 block text-[11px] text-[var(--foreground-dim)]">Let NemoClaw choose.</span></span>
@@ -266,9 +268,13 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre
<input type="checkbox" checked={createInferenceMode === 'vllm'} onChange={() => setCreateInferenceMode('vllm')} className="mt-0.5 h-4 w-4 accent-[var(--nvidia-green)]" />
<span><span className="block text-xs font-mono uppercase tracking-wider">Use vLLM in experimental mode</span><span className="mt-1 block text-[11px] text-[var(--foreground-dim)]">Sets NEMOCLAW_EXPERIMENTAL and vLLM.</span></span>
</label>
<label className={`flex items-start gap-3 rounded-sm border p-3 text-sm text-[var(--foreground)] ${createInferenceMode === 'nim' ? 'border-[var(--nvidia-green)] bg-[rgba(118,185,0,0.08)]' : 'border-[var(--border-subtle)] bg-[var(--background-tertiary)]'}`}>
<input type="checkbox" checked={createInferenceMode === 'nim'} onChange={() => setCreateInferenceMode('nim')} className="mt-0.5 h-4 w-4 accent-[var(--nvidia-green)]" />
<span><span className="block text-xs font-mono uppercase tracking-wider">Use NVIDIA NIM</span><span className="mt-1 block text-[11px] text-[var(--foreground-dim)]">Uses the experimental local NIM provider.</span></span>
<label className={`flex items-start gap-3 rounded-sm border p-3 text-sm text-[var(--foreground)] ${createInferenceMode === 'nvidia' ? 'border-[var(--nvidia-green)] bg-[rgba(118,185,0,0.08)]' : 'border-[var(--border-subtle)] bg-[var(--background-tertiary)]'}`}>
<input type="checkbox" checked={createInferenceMode === 'nvidia'} onChange={() => setCreateInferenceMode('nvidia')} className="mt-0.5 h-4 w-4 accent-[var(--nvidia-green)]" />
<span><span className="block text-xs font-mono uppercase tracking-wider">NVIDIA hosted API</span><span className="mt-1 block text-[11px] text-[var(--foreground-dim)]">Uses NemoClaw build provider and requires an nvapi-* key.</span></span>
</label>
<label className={`flex items-start gap-3 rounded-sm border p-3 text-sm text-[var(--foreground)] ${createInferenceMode === 'compatible' ? 'border-[var(--nvidia-green)] bg-[rgba(118,185,0,0.08)]' : 'border-[var(--border-subtle)] bg-[var(--background-tertiary)]'}`}>
<input type="checkbox" checked={createInferenceMode === 'compatible'} onChange={() => setCreateInferenceMode('compatible')} className="mt-0.5 h-4 w-4 accent-[var(--nvidia-green)]" />
<span><span className="block text-xs font-mono uppercase tracking-wider">OpenAI-compatible endpoint</span><span className="mt-1 block text-[11px] text-[var(--foreground-dim)]">Sets NEMOCLAW_PROVIDER=custom, endpoint URL, and compatible API key.</span></span>
</label>
</div>
{createInferenceMode !== 'auto' && (
@@ -277,10 +283,16 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre
<label className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">Model</label>
<input value={createInferenceModel} onChange={(e) => 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)]" />
</div>
{createInferenceMode === 'nim' && (
{createInferenceMode === 'compatible' && (
<div className="space-y-2">
<label className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">NVIDIA API Key</label>
<input type="password" value={createNvidiaApiKey} onChange={(e) => 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)]" />
<label className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">Endpoint URL</label>
<input value={createInferenceEndpointUrl} onChange={(e) => 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)]" />
</div>
)}
{(createInferenceMode === 'nvidia' || createInferenceMode === 'compatible') && (
<div className="space-y-2">
<label className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">Provider API Key</label>
<input type="password" value={createNvidiaApiKey} onChange={(e) => 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)]" />
</div>
)}
</div>