@@ -105,7 +105,17 @@ async function deploy(instanceName) {
105105 if ( isRepoPrivate ( "NVIDIA/OpenShell" ) ) {
106106 await ensureGithubToken ( ) ;
107107 }
108- const name = instanceName ;
108+ const name = instanceName . trim ( ) ;
109+
110+ // Validate: same RFC 1123 subdomain rules used for sandbox names — lowercase
111+ // alphanumeric and hyphens, must start and end with alphanumeric.
112+ if ( ! / ^ [ a - z 0 - 9 ] ( [ a - z 0 - 9 - ] * [ a - z 0 - 9 ] ) ? $ / . test ( name ) || name . length > 253 ) {
113+ console . error ( ` Invalid instance name: '${ name } '` ) ;
114+ console . error ( " Names must be lowercase, contain only letters, numbers, and hyphens," ) ;
115+ console . error ( " and must start and end with a letter or number (max 253 chars)." ) ;
116+ process . exit ( 1 ) ;
117+ }
118+
109119 const gpu = process . env . NEMOCLAW_GPU || "a2-highgpu-1g:nvidia-tesla-a100:1" ;
110120
111121 console . log ( "" ) ;
@@ -127,7 +137,7 @@ async function deploy(instanceName) {
127137
128138 if ( ! exists ) {
129139 console . log ( ` Creating Brev instance '${ name } ' (${ gpu } )...` ) ;
130- run ( `brev create ${ name } --gpu "${ gpu } "` ) ;
140+ run ( `brev create " ${ name } " --gpu "${ gpu } "` ) ;
131141 } else {
132142 console . log ( ` Brev instance '${ name } ' already exists.` ) ;
133143 }
@@ -137,7 +147,7 @@ async function deploy(instanceName) {
137147 console . log ( " Waiting for SSH..." ) ;
138148 for ( let i = 0 ; i < 60 ; i ++ ) {
139149 try {
140- execSync ( `ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no ${ name } 'echo ok' 2>/dev/null` , { encoding : "utf-8" , stdio : "pipe" } ) ;
150+ execSync ( `ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no " ${ name } " 'echo ok' 2>/dev/null` , { encoding : "utf-8" , stdio : "pipe" } ) ;
141151 break ;
142152 } catch {
143153 if ( i === 59 ) {
@@ -149,8 +159,8 @@ async function deploy(instanceName) {
149159 }
150160
151161 console . log ( " Syncing NemoClaw to VM..." ) ;
152- run ( `ssh -o StrictHostKeyChecking=no -o LogLevel=ERROR ${ name } 'mkdir -p /home/ubuntu/nemoclaw'` ) ;
153- run ( `rsync -az --delete --exclude node_modules --exclude .git --exclude src -e "ssh -o StrictHostKeyChecking=no -o LogLevel=ERROR" "${ ROOT } /scripts" "${ ROOT } /Dockerfile" "${ ROOT } /nemoclaw" "${ ROOT } /nemoclaw-blueprint" "${ ROOT } /bin" "${ ROOT } /package.json" ${ name } :/home/ubuntu/nemoclaw/` ) ;
162+ run ( `ssh -o StrictHostKeyChecking=no -o LogLevel=ERROR " ${ name } " 'mkdir -p /home/ubuntu/nemoclaw'` ) ;
163+ run ( `rsync -az --delete --exclude node_modules --exclude .git --exclude src -e "ssh -o StrictHostKeyChecking=no -o LogLevel=ERROR" "${ ROOT } /scripts" "${ ROOT } /Dockerfile" "${ ROOT } /nemoclaw" "${ ROOT } /nemoclaw-blueprint" "${ ROOT } /bin" "${ ROOT } /package.json" " ${ name } " :/home/ubuntu/nemoclaw/` ) ;
154164
155165 const envLines = [ `NVIDIA_API_KEY=${ process . env . NVIDIA_API_KEY } ` ] ;
156166 const ghToken = process . env . GITHUB_TOKEN ;
@@ -159,21 +169,21 @@ async function deploy(instanceName) {
159169 if ( tgToken ) envLines . push ( `TELEGRAM_BOT_TOKEN=${ tgToken } ` ) ;
160170 const envTmp = path . join ( os . tmpdir ( ) , `nemoclaw-env-${ Date . now ( ) } ` ) ;
161171 fs . writeFileSync ( envTmp , envLines . join ( "\n" ) + "\n" , { mode : 0o600 } ) ;
162- run ( `scp -q -o StrictHostKeyChecking=no -o LogLevel=ERROR "${ envTmp } " ${ name } :/home/ubuntu/nemoclaw/.env` ) ;
172+ run ( `scp -q -o StrictHostKeyChecking=no -o LogLevel=ERROR "${ envTmp } " " ${ name } " :/home/ubuntu/nemoclaw/.env` ) ;
163173 fs . unlinkSync ( envTmp ) ;
164174
165175 console . log ( " Running setup..." ) ;
166- runInteractive ( `ssh -t -o StrictHostKeyChecking=no -o LogLevel=ERROR ${ name } 'cd /home/ubuntu/nemoclaw && set -a && . .env && set +a && bash scripts/brev-setup.sh'` ) ;
176+ runInteractive ( `ssh -t -o StrictHostKeyChecking=no -o LogLevel=ERROR " ${ name } " 'cd /home/ubuntu/nemoclaw && set -a && . .env && set +a && bash scripts/brev-setup.sh'` ) ;
167177
168178 if ( tgToken ) {
169179 console . log ( " Starting services..." ) ;
170- run ( `ssh -o StrictHostKeyChecking=no -o LogLevel=ERROR ${ name } 'cd /home/ubuntu/nemoclaw && set -a && . .env && set +a && bash scripts/start-services.sh'` ) ;
180+ run ( `ssh -o StrictHostKeyChecking=no -o LogLevel=ERROR " ${ name } " 'cd /home/ubuntu/nemoclaw && set -a && . .env && set +a && bash scripts/start-services.sh'` ) ;
171181 }
172182
173183 console . log ( "" ) ;
174184 console . log ( " Connecting to sandbox..." ) ;
175185 console . log ( "" ) ;
176- runInteractive ( `ssh -t -o StrictHostKeyChecking=no -o LogLevel=ERROR ${ name } 'cd /home/ubuntu/nemoclaw && set -a && . .env && set +a && openshell sandbox connect nemoclaw'` ) ;
186+ runInteractive ( `ssh -t -o StrictHostKeyChecking=no -o LogLevel=ERROR " ${ name } " 'cd /home/ubuntu/nemoclaw && set -a && . .env && set +a && openshell sandbox connect nemoclaw'` ) ;
177187}
178188
179189async function start ( ) {
0 commit comments