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