fix: align sandbox name validation with NemoClaw (#51)

Co-authored-by: mmckeen-nv <mmckeen-nv@users.noreply.github.com>
This commit is contained in:
mmckeen-nv
2026-09-19 23:09:39 -07:00
committed by GitHub
co-authored by mmckeen-nv
parent f70c10d767
commit 52fe7a2d83
5 changed files with 22 additions and 7 deletions
+2
View File
@@ -60,6 +60,8 @@ Runtime/toolchain versions used during development:
- OpenShell CLI and gateway compatible with current `NVIDIA/NemoClaw` blueprint constraints - OpenShell CLI and gateway compatible with current `NVIDIA/NemoClaw` blueprint constraints
- NemoClaw CLI compatible with the current `NVIDIA/NemoClaw` repo - NemoClaw CLI compatible with the current `NVIDIA/NemoClaw` repo
Sandbox creation follows NemoClaw's OpenShell routed-name contract: names are 1-19 characters, start with a lowercase letter, contain only lowercase letters, numbers, and single internal hyphens, and end with a letter or number.
Use `./install_versioned_nemoclaw_openshell.sh` to install or refresh the OpenShell/NemoClaw pair. Override `OPENSHELL_VERSION`, `NEMOCLAW_INSTALL_REF`, or `OPENCLAW_VERSION` only when intentionally testing a different pair. Use `./install_versioned_nemoclaw_openshell.sh` to install or refresh the OpenShell/NemoClaw pair. Override `OPENSHELL_VERSION`, `NEMOCLAW_INSTALL_REF`, or `OPENCLAW_VERSION` only when intentionally testing a different pair.
The app uses Next.js `15.5.15`, React `18.3.1`, TypeScript, Tailwind CSS, `ws`, `node-pty`, and the official MCP TypeScript SDK. The app uses Next.js `15.5.15`, React `18.3.1`, TypeScript, Tailwind CSS, `ws`, `node-pty`, and the official MCP TypeScript SDK.
+3 -3
View File
@@ -27,9 +27,9 @@ const NEMOCLAW_STATE_ROOT = path.join(process.env.HOME || "/tmp", ".nemoclaw")
function validateSandboxName(name: string) { function validateSandboxName(name: string) {
if (!name || typeof name !== "string") throw new Error("sandbox name is required") if (!name || typeof name !== "string") throw new Error("sandbox name is required")
if (name.length > 63) throw new Error("sandbox name too long (max 63 chars)") if (name.length > 19) throw new Error("sandbox name too long (max 19 chars)")
if (!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(name)) { if (!/^(?!.*--)[a-z]([a-z0-9-]*[a-z0-9])?$/.test(name)) {
throw new Error("sandbox name must be lowercase alphanumeric with optional internal hyphens") throw new Error("sandbox name must start with a lowercase letter and contain only lowercase letters, numbers, and single internal hyphens")
} }
return name return name
} }
+2 -2
View File
@@ -220,8 +220,8 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre
))} ))}
</div> </div>
<div> <div>
<label className="text-xs uppercase tracking-wider text-[var(--foreground-dim)]">Sandbox Name<FieldHelp text="Lowercase letters, numbers, and hyphens only." /></label> <label className="text-xs uppercase tracking-wider text-[var(--foreground-dim)]">Sandbox Name<FieldHelp text="1-19 characters; start with a lowercase letter; use lowercase letters, numbers, and single internal hyphens only." /></label>
<input value={sandboxName} onChange={(e) => setSandboxName(e.target.value)} placeholder={selectedBlueprint === 'nemoclaw-hermes' ? 'my-hermes' : selectedBlueprint === 'nemoclaw-deepagents-code' ? 'my-deepagents-code' : selectedBlueprint === 'nemoclaw-blueprint' ? 'my-assistant' : selectedBlueprint === 'redeploy-image' ? 'my-assistant-copy' : '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)]" /> <input value={sandboxName} onChange={(e) => setSandboxName(e.target.value)} maxLength={19} pattern="(?!.*--)[a-z](?:[a-z0-9-]*[a-z0-9])?" placeholder={selectedBlueprint === 'nemoclaw-hermes' ? 'my-hermes' : selectedBlueprint === 'nemoclaw-deepagents-code' ? 'my-deepagents-code' : selectedBlueprint === 'nemoclaw-blueprint' ? 'my-assistant' : selectedBlueprint === 'redeploy-image' ? 'my-assistant-copy' : '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)] focus:outline-none focus:border-[var(--nvidia-green)]" />
</div> </div>
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-4 space-y-4"> <div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-4 space-y-4">
<div> <div>
+6 -2
View File
@@ -51,7 +51,8 @@ function contentDispositionFileName(value: string | null, fallback: string) {
function defaultCloneName(source?: SandboxInventoryItem) { function defaultCloneName(source?: SandboxInventoryItem) {
if (!source) return "" if (!source) return ""
return `${source.name.replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "")}-clone`.slice(0, 63) const base = source.name.replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").slice(0, 13).replace(/-+$/g, "")
return `${base || "sandbox"}-clone`
} }
export default function WizardPanel({ export default function WizardPanel({
@@ -134,7 +135,7 @@ export default function WizardPanel({
const canContinue = (() => { const canContinue = (() => {
if (activeStep === "source") return Boolean(sourceSandbox) if (activeStep === "source") return Boolean(sourceSandbox)
if (activeStep === "target") return /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(targetName) && targetName.length <= 63 if (activeStep === "target") return /^(?!.*--)[a-z]([a-z0-9-]*[a-z0-9])?$/.test(targetName) && targetName.length <= 19
if (activeStep === "options") return Boolean(backupPath.trim() && restorePath.trim()) if (activeStep === "options") return Boolean(backupPath.trim() && restorePath.trim())
if (activeStep === "review") return Boolean(sourceSandbox && targetName.trim()) if (activeStep === "review") return Boolean(sourceSandbox && targetName.trim())
return false return false
@@ -626,9 +627,12 @@ export default function WizardPanel({
<input <input
value={targetName} value={targetName}
onChange={(event) => setTargetName(event.target.value)} onChange={(event) => setTargetName(event.target.value)}
maxLength={19}
pattern="(?!.*--)[a-z](?:[a-z0-9-]*[a-z0-9])?"
placeholder="source-clone" placeholder="source-clone"
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)] focus:outline-none focus:border-[var(--nvidia-green)]" 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)] focus:outline-none focus:border-[var(--nvidia-green)]"
/> />
<span className="text-[11px] text-[var(--foreground-dim)]">1-19 characters; start with a lowercase letter; no consecutive hyphens.</span>
</label> </label>
{activeBlueprint?.supportsTailscale && ( {activeBlueprint?.supportsTailscale && (
<label className="flex items-center gap-3 text-sm font-mono text-[var(--foreground)]"> <label className="flex items-center gap-3 text-sm font-mono text-[var(--foreground)]">
+9
View File
@@ -24,6 +24,7 @@ const versionedInstallerPath = path.join(root, 'install_versioned_nemoclaw_opens
const hookPath = path.join(root, 'app/hooks/useSandboxInventory.ts') const hookPath = path.join(root, 'app/hooks/useSandboxInventory.ts')
const pagePath = path.join(root, 'app/page.tsx') const pagePath = path.join(root, 'app/page.tsx')
const configPanelPath = path.join(root, 'app/components/ConfigurationPanel.tsx') const configPanelPath = path.join(root, 'app/components/ConfigurationPanel.tsx')
const wizardPanelPath = path.join(root, 'app/components/WizardPanel.tsx')
const activityPanelPath = path.join(root, 'app/components/ActivityPanel.tsx') const activityPanelPath = path.join(root, 'app/components/ActivityPanel.tsx')
const inferencePanelPath = path.join(root, 'app/components/InferenceEndpointPanel.tsx') const inferencePanelPath = path.join(root, 'app/components/InferenceEndpointPanel.tsx')
const sandboxInferencePanelPath = path.join(root, 'app/components/SandboxInferencePanel.tsx') const sandboxInferencePanelPath = path.join(root, 'app/components/SandboxInferencePanel.tsx')
@@ -53,6 +54,7 @@ const versionedInstallerSource = await readFile(versionedInstallerPath, 'utf8')
const hookSource = await readFile(hookPath, 'utf8') const hookSource = await readFile(hookPath, 'utf8')
const pageSource = await readFile(pagePath, 'utf8') const pageSource = await readFile(pagePath, 'utf8')
const configPanelSource = await readFile(configPanelPath, 'utf8') const configPanelSource = await readFile(configPanelPath, 'utf8')
const wizardPanelSource = await readFile(wizardPanelPath, 'utf8')
const activityPanelSource = await readFile(activityPanelPath, 'utf8') const activityPanelSource = await readFile(activityPanelPath, 'utf8')
const inferencePanelSource = await readFile(inferencePanelPath, 'utf8') const inferencePanelSource = await readFile(inferencePanelPath, 'utf8')
const sandboxInferencePanelSource = await readFile(sandboxInferencePanelPath, 'utf8') const sandboxInferencePanelSource = await readFile(sandboxInferencePanelPath, 'utf8')
@@ -94,6 +96,8 @@ assert.match(createRouteSource, /mode === "none"[\s\S]*return \["--no-gpu"\]/, '
assert.match(createRouteSource, /openShellGpuArgs\(mode: CreateGpuMode\)/, 'OpenShell create paths must share GPU request handling') 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.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, /NEMOCLAW_SANDBOX_NAME: sandboxName/, 'blueprint create must pass the requested sandbox name to NemoClaw onboarding')
assert.match(createRouteSource, /name\.length > 19/, 'create API must enforce NemoClaw\'s 19-character routed sandbox-name limit')
assert.match(createRouteSource, /\^\(\?!\.\*--\)\[a-z\]/, 'create API must require a leading lowercase letter and reject consecutive hyphens')
assert.match(createRouteSource, /id: "redeploy-image"/, 'create API must expose image redeploy as a sandbox creation path') 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: "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, /label: "Fresh NemoClaw Image"/, 'full rebuild path must be labeled as fresh image creation')
@@ -328,6 +332,11 @@ assert.match(configPanelSource, /createInference/, 'create panel must send creat
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-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-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, /selectedBlueprint === 'nemoclaw-deepagents-code' \? 'my-deepagents-code'/, 'create panel must provide a Deep Agents Code-specific sandbox name placeholder')
assert.match(configPanelSource, /maxLength=\{19\}/, 'create panel must expose NemoClaw\'s 19-character sandbox-name limit')
assert.match(configPanelSource, /single internal hyphens only/, 'create panel must explain the canonical sandbox-name grammar')
assert.match(wizardPanelSource, /targetName\.length <= 19/, 'clone wizard must enforce NemoClaw\'s 19-character sandbox-name limit')
assert.match(wizardPanelSource, /\^\(\?!\.\*--\)\[a-z\]/, 'clone wizard must reject leading digits and consecutive hyphens')
assert.match(wizardPanelSource, /\.slice\(0, 13\)[\s\S]*-clone/, 'clone wizard must keep generated clone names within the 19-character limit')
assert.match(configPanelSource, /useState<string>\('redeploy-image'\)/, 'create panel must default to quick deploy') 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') assert.doesNotMatch(configPanelSource, /Source Sandbox|sourceSandboxName/, 'basic create panel must not require choosing a source image')