From 48d2d00d413b680833b3cbd36e0f08a9897c5b3b Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 27 Apr 2026 16:55:33 +0000 Subject: [PATCH] Use current NemoClaw onboard flow for sandbox creation --- app/api/sandbox/create/route.ts | 50 +++++++++++++++++++++++++++----- install.sh | 5 ++-- tests/portable-install-check.mjs | 14 +++++---- 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/app/api/sandbox/create/route.ts b/app/api/sandbox/create/route.ts index a469e4a..1d1fbbf 100644 --- a/app/api/sandbox/create/route.ts +++ b/app/api/sandbox/create/route.ts @@ -2,7 +2,17 @@ import { NextResponse } from "next/server" import { execFile, spawn } from "node:child_process" import { promisify } from "node:util" import { inspectSandbox } from "@/app/lib/openshellHost" -import { commandExists, HOST_PATH, NEMOCLAW_SETUP, NEMOCLAW_SETUP_CANDIDATES, OPENSHELL_BIN } from "@/app/lib/hostCommands" +import { + commandExists, + HOST_PATH, + NEMOCLAW_BIN, + NEMOCLAW_BIN_CANDIDATES, + NEMOCLAW_CWD, + NEMOCLAW_SETUP, + NEMOCLAW_SETUP_CANDIDATES, + NODE_BIN, + OPENSHELL_BIN, +} from "@/app/lib/hostCommands" const execFileAsync = promisify(execFile) @@ -41,10 +51,24 @@ function appendNote(...parts: Array) { return parts.filter(Boolean).join(" ") } -function requireNemoClawSetup() { - if (NEMOCLAW_SETUP && commandExists(NEMOCLAW_SETUP)) return NEMOCLAW_SETUP +type NemoClawCreateCommand = { + file: string + args: string[] + mode: "cli-onboard" | "legacy-setup" +} + +function buildNemoClawCreateCommand(): NemoClawCreateCommand { + if (NEMOCLAW_BIN && commandExists(NEMOCLAW_BIN)) { + const args = ["onboard", "--non-interactive", "--recreate-sandbox", "--yes-i-accept-third-party-software"] + return /\.(?:c?m?js|ts)$/i.test(NEMOCLAW_BIN) + ? { file: NODE_BIN, args: [NEMOCLAW_BIN, ...args], mode: "cli-onboard" } + : { file: NEMOCLAW_BIN, args, mode: "cli-onboard" } + } + if (NEMOCLAW_SETUP && commandExists(NEMOCLAW_SETUP)) { + return { file: "/bin/bash", args: [NEMOCLAW_SETUP], mode: "legacy-setup" } + } throw new Error( - `NemoClaw blueprint setup script was not found. Install NemoClaw under your Linux home directory, or set NEMOCLAW_SETUP in .env.local to the absolute path of scripts/setup.sh. Searched: ${NEMOCLAW_SETUP_CANDIDATES.join(", ") || "no candidates"}.`, + `NemoClaw CLI was not found. Install the current NemoClaw CLI under your Linux home directory, or set NEMOCLAW_BIN in .env.local. Searched CLI: ${NEMOCLAW_BIN_CANDIDATES.join(", ") || "no candidates"}. Legacy setup candidates: ${NEMOCLAW_SETUP_CANDIDATES.join(", ") || "none"}.`, ) } @@ -87,11 +111,12 @@ async function verifySandboxCreation(sandboxName: string): Promise