@@ -183,20 +183,24 @@ function isSandboxReady(output, sandboxName) {
183183 * @returns {boolean }
184184 */
185185function hasStaleGateway ( gwInfoOutput ) {
186- return typeof gwInfoOutput === "string" && gwInfoOutput . length > 0 && gwInfoOutput . includes ( GATEWAY_NAME ) ;
186+ return (
187+ typeof gwInfoOutput === "string" &&
188+ gwInfoOutput . length > 0 &&
189+ gwInfoOutput . includes ( `Gateway: ${ GATEWAY_NAME } ` ) &&
190+ ! gwInfoOutput . includes ( "No gateway metadata found" )
191+ ) ;
192+ }
193+
194+ function isSelectedGateway ( statusOutput = "" , gatewayName = GATEWAY_NAME ) {
195+ return typeof statusOutput === "string" && statusOutput . includes ( `Gateway: ${ gatewayName } ` ) ;
187196}
188197
189- function isGatewayHealthy ( statusOutput = "" , gwInfoOutput = "" , activeGatewayInfoOutput = "" ) {
198+ function isGatewayHealthy ( statusOutput = "" , gwInfoOutput = "" , _activeGatewayInfoOutput = "" ) {
190199 const connected = typeof statusOutput === "string" && statusOutput . includes ( "Connected" ) ;
191200 if ( ! connected ) return false ;
192201
193202 const namedGatewayKnown = hasStaleGateway ( gwInfoOutput ) ;
194- const activeGatewayKnown =
195- typeof activeGatewayInfoOutput === "string" &&
196- activeGatewayInfoOutput . includes ( "Gateway endpoint:" ) &&
197- ! activeGatewayInfoOutput . includes ( "No gateway metadata found" ) ;
198-
199- return namedGatewayKnown || activeGatewayKnown ;
203+ return namedGatewayKnown || isSelectedGateway ( statusOutput ) ;
200204}
201205
202206function getGatewayReuseState ( statusOutput = "" , gwInfoOutput = "" , activeGatewayInfoOutput = "" ) {
@@ -1223,6 +1227,24 @@ function getRequestedModelHint(nonInteractive = isNonInteractive()) {
12231227 return getNonInteractiveModel ( providerKey ) ;
12241228}
12251229
1230+ function getEffectiveProviderName ( providerKey ) {
1231+ if ( ! providerKey ) return null ;
1232+ if ( REMOTE_PROVIDER_CONFIG [ providerKey ] ) {
1233+ return REMOTE_PROVIDER_CONFIG [ providerKey ] . providerName ;
1234+ }
1235+
1236+ switch ( providerKey ) {
1237+ case "nim-local" :
1238+ return "nvidia-nim" ;
1239+ case "ollama" :
1240+ return "ollama-local" ;
1241+ case "vllm" :
1242+ return "vllm-local" ;
1243+ default :
1244+ return providerKey ;
1245+ }
1246+ }
1247+
12261248function getResumeConfigConflicts ( session , opts = { } ) {
12271249 const conflicts = [ ] ;
12281250 const nonInteractive = opts . nonInteractive ?? isNonInteractive ( ) ;
@@ -1237,10 +1259,11 @@ function getResumeConfigConflicts(session, opts = {}) {
12371259 }
12381260
12391261 const requestedProvider = getRequestedProviderHint ( nonInteractive ) ;
1240- if ( requestedProvider && session ?. provider && requestedProvider !== session . provider ) {
1262+ const effectiveRequestedProvider = getEffectiveProviderName ( requestedProvider ) ;
1263+ if ( effectiveRequestedProvider && session ?. provider && effectiveRequestedProvider !== session . provider ) {
12411264 conflicts . push ( {
12421265 field : "provider" ,
1243- requested : requestedProvider ,
1266+ requested : effectiveRequestedProvider ,
12441267 recorded : session . provider ,
12451268 } ) ;
12461269 }
@@ -1562,7 +1585,7 @@ function getGatewayStartEnv() {
15621585async function recoverGatewayRuntime ( ) {
15631586 runOpenshell ( [ "gateway" , "select" , GATEWAY_NAME ] , { ignoreError : true } ) ;
15641587 let status = runCaptureOpenshell ( [ "status" ] , { ignoreError : true } ) ;
1565- if ( status . includes ( "Connected" ) ) {
1588+ if ( status . includes ( "Connected" ) && isSelectedGateway ( status ) ) {
15661589 process . env . OPENSHELL_GATEWAY = GATEWAY_NAME ;
15671590 return true ;
15681591 }
@@ -1575,7 +1598,7 @@ async function recoverGatewayRuntime() {
15751598
15761599 for ( let i = 0 ; i < 5 ; i ++ ) {
15771600 status = runCaptureOpenshell ( [ "status" ] , { ignoreError : true } ) ;
1578- if ( status . includes ( "Connected" ) ) {
1601+ if ( status . includes ( "Connected" ) && isSelectedGateway ( status ) ) {
15791602 process . env . OPENSHELL_GATEWAY = GATEWAY_NAME ;
15801603 const runtime = getContainerRuntime ( ) ;
15811604 if ( shouldPatchCoredns ( runtime ) ) {
@@ -1591,9 +1614,7 @@ async function recoverGatewayRuntime() {
15911614
15921615// ── Step 3: Sandbox ──────────────────────────────────────────────
15931616
1594- async function createSandbox ( gpu , model , provider , preferredInferenceApi = null ) {
1595- step ( 5 , 7 , "Creating sandbox" ) ;
1596-
1617+ async function promptValidatedSandboxName ( ) {
15971618 const nameAnswer = await promptOrDefault (
15981619 " Sandbox name (lowercase, numbers, hyphens) [my-assistant]: " ,
15991620 "NEMOCLAW_SANDBOX_NAME" , "my-assistant"
@@ -1609,6 +1630,14 @@ async function createSandbox(gpu, model, provider, preferredInferenceApi = null)
16091630 process . exit ( 1 ) ;
16101631 }
16111632
1633+ return sandboxName ;
1634+ }
1635+
1636+ async function createSandbox ( gpu , model , provider , preferredInferenceApi = null , sandboxNameOverride = null ) {
1637+ step ( 5 , 7 , "Creating sandbox" ) ;
1638+
1639+ const sandboxName = sandboxNameOverride || ( await promptValidatedSandboxName ( ) ) ;
1640+
16121641 // Reconcile local registry state with the live OpenShell gateway state.
16131642 const liveExists = pruneStaleSandboxEntry ( sandboxName ) ;
16141643
@@ -2501,9 +2530,9 @@ async function onboard(opts = {}) {
25012530 onboardSession . markStepComplete ( "preflight" ) ;
25022531 }
25032532
2504- const gatewayStatus = runCapture ( "openshell status 2>&1" , { ignoreError : true } ) ;
2505- const gatewayInfo = runCapture ( "openshell gateway info -g nemoclaw 2>/dev/null" , { ignoreError : true } ) ;
2506- const activeGatewayInfo = runCapture ( "openshell gateway info 2>&1" , { ignoreError : true } ) ;
2533+ const gatewayStatus = runCaptureOpenshell ( [ " status" ] , { ignoreError : true } ) ;
2534+ const gatewayInfo = runCaptureOpenshell ( [ " gateway" , " info" , "-g" , GATEWAY_NAME ] , { ignoreError : true } ) ;
2535+ const activeGatewayInfo = runCaptureOpenshell ( [ " gateway" , " info" ] , { ignoreError : true } ) ;
25072536 const gatewayReuseState = getGatewayReuseState ( gatewayStatus , gatewayInfo , activeGatewayInfo ) ;
25082537 const resumeGateway =
25092538 resume &&
@@ -2585,8 +2614,9 @@ async function onboard(opts = {}) {
25852614 }
25862615 }
25872616 }
2588- startRecordedStep ( "sandbox" , { provider, model } ) ;
2589- sandboxName = await createSandbox ( gpu , model , provider , preferredInferenceApi ) ;
2617+ sandboxName = sandboxName || ( await promptValidatedSandboxName ( ) ) ;
2618+ startRecordedStep ( "sandbox" , { sandboxName, provider, model } ) ;
2619+ sandboxName = await createSandbox ( gpu , model , provider , preferredInferenceApi , sandboxName ) ;
25902620 onboardSession . markStepComplete ( "sandbox" , { sandboxName, provider, model, nimContainer } ) ;
25912621 }
25922622
0 commit comments