Add remote controller node wizard
This commit is contained in:
@@ -12,6 +12,25 @@ type BlueprintOption = {
|
||||
|
||||
type WizardStep = "source" | "target" | "options" | "review" | "run"
|
||||
|
||||
type ControllerPlan = {
|
||||
controller: {
|
||||
name: string
|
||||
url: string
|
||||
host: string
|
||||
dashboardPort: number
|
||||
terminalPort: number
|
||||
installDir: string
|
||||
}
|
||||
env: string
|
||||
commands: {
|
||||
ssh: string
|
||||
localBootstrap: string
|
||||
start: string
|
||||
terminal: string
|
||||
}
|
||||
checks: string[]
|
||||
}
|
||||
|
||||
const steps: Array<{ key: WizardStep; label: string }> = [
|
||||
{ key: "source", label: "Source" },
|
||||
{ key: "target", label: "Target" },
|
||||
@@ -51,6 +70,19 @@ export default function WizardPanel({
|
||||
const [running, setRunning] = useState(false)
|
||||
const [message, setMessage] = useState("")
|
||||
const [runLog, setRunLog] = useState<string[]>([])
|
||||
const [controllerName, setControllerName] = useState("remote-controller")
|
||||
const [controllerHost, setControllerHost] = useState("")
|
||||
const [sshTarget, setSshTarget] = useState("")
|
||||
const [installDir, setInstallDir] = useState("openshell-control")
|
||||
const [repoUrl, setRepoUrl] = useState("https://github.com/NVIDIA/nemoclaw-dashboard.git")
|
||||
const [dashboardPort, setDashboardPort] = useState("3000")
|
||||
const [terminalPort, setTerminalPort] = useState("3011")
|
||||
const [openClawDashboardUrl, setOpenClawDashboardUrl] = useState("http://127.0.0.1:18789/")
|
||||
const [openshellGateway, setOpenshellGateway] = useState("nemoclaw")
|
||||
const [exposePublicly, setExposePublicly] = useState(false)
|
||||
const [controllerPlan, setControllerPlan] = useState<ControllerPlan | null>(null)
|
||||
const [controllerMessage, setControllerMessage] = useState("")
|
||||
const [controllerPlanning, setControllerPlanning] = useState(false)
|
||||
|
||||
const sourceSandbox = useMemo(
|
||||
() => sandboxes.find((sandbox) => sandbox.id === sourceSandboxId) || null,
|
||||
@@ -164,16 +196,167 @@ export default function WizardPanel({
|
||||
}
|
||||
}
|
||||
|
||||
async function generateControllerPlan() {
|
||||
try {
|
||||
setControllerPlanning(true)
|
||||
setControllerMessage("")
|
||||
setControllerPlan(null)
|
||||
|
||||
const response = await fetch("/api/controller-node/plan", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
controllerName,
|
||||
controllerHost,
|
||||
sshTarget,
|
||||
installDir,
|
||||
repoUrl,
|
||||
dashboardPort,
|
||||
terminalPort,
|
||||
openClawDashboardUrl,
|
||||
openshellGateway,
|
||||
exposePublicly,
|
||||
}),
|
||||
})
|
||||
const data = await response.json()
|
||||
if (!response.ok) throw new Error(data.error || "Failed to generate controller node plan")
|
||||
setControllerPlan(data)
|
||||
setControllerMessage(`Launch kit ready for ${data.controller.url}.`)
|
||||
} catch (error) {
|
||||
setControllerMessage(error instanceof Error ? error.message : "Failed to generate controller node plan")
|
||||
} finally {
|
||||
setControllerPlanning(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function copyText(value: string, label: string) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(value)
|
||||
setControllerMessage(`${label} copied.`)
|
||||
} catch {
|
||||
setControllerMessage("Clipboard access was blocked. Select the command text manually.")
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<section className="panel p-8">
|
||||
<p className="text-[10px] font-mono uppercase tracking-wider text-[var(--nvidia-green)]">Guided Tasks</p>
|
||||
<h1 className="mt-2 text-xl font-semibold uppercase tracking-wider text-[var(--foreground)]">Wizards</h1>
|
||||
<p className="mt-2 max-w-3xl text-sm text-[var(--foreground-dim)]">
|
||||
Step-by-step workflows for common operations. The first wizard clones one sandbox into another using backup and restore.
|
||||
Step-by-step workflows for common operations, including remote controller bootstrap and sandbox cloning.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section className="panel overflow-hidden">
|
||||
<div className="border-b border-[var(--border-subtle)] p-5">
|
||||
<div className="flex items-center justify-between gap-4 max-md:flex-col max-md:items-start">
|
||||
<div>
|
||||
<h2 className="text-sm font-semibold uppercase tracking-wider text-[var(--foreground)]">Spawn a Controller Node</h2>
|
||||
<p className="mt-1 text-xs text-[var(--foreground-dim)]">Prepare a remote VPS to run OpenShell Control near another OpenShell gateway or sandbox host.</p>
|
||||
</div>
|
||||
<span className="status-chip border border-[var(--border-subtle)] bg-[var(--background-tertiary)] px-2.5 py-1 text-[var(--foreground-dim)]">
|
||||
remote control plane
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 gap-5 p-5 xl:grid-cols-[minmax(0,1fr)_minmax(360px,0.8fr)]">
|
||||
<div className="space-y-5">
|
||||
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||
<label className="block space-y-2">
|
||||
<span className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">Controller Name</span>
|
||||
<input value={controllerName} onChange={(event) => setControllerName(event.target.value)} 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)]" />
|
||||
</label>
|
||||
<label className="block space-y-2">
|
||||
<span className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">Controller Host</span>
|
||||
<input value={controllerHost} onChange={(event) => setControllerHost(event.target.value)} placeholder="vps.example.com" 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)]" />
|
||||
</label>
|
||||
<label className="block space-y-2">
|
||||
<span className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">SSH Target</span>
|
||||
<input value={sshTarget} onChange={(event) => setSshTarget(event.target.value)} placeholder="ubuntu@vps.example.com" 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)]" />
|
||||
</label>
|
||||
<label className="block space-y-2">
|
||||
<span className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">Install Directory</span>
|
||||
<input value={installDir} onChange={(event) => setInstallDir(event.target.value)} 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)]" />
|
||||
</label>
|
||||
<label className="block space-y-2 md:col-span-2">
|
||||
<span className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">Repository URL</span>
|
||||
<input value={repoUrl} onChange={(event) => setRepoUrl(event.target.value)} 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)]" />
|
||||
</label>
|
||||
<label className="block space-y-2">
|
||||
<span className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">Dashboard Port</span>
|
||||
<input value={dashboardPort} onChange={(event) => setDashboardPort(event.target.value)} 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)]" />
|
||||
</label>
|
||||
<label className="block space-y-2">
|
||||
<span className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">Terminal Port</span>
|
||||
<input value={terminalPort} onChange={(event) => setTerminalPort(event.target.value)} 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)]" />
|
||||
</label>
|
||||
<label className="block space-y-2">
|
||||
<span className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">OpenClaw Dashboard URL</span>
|
||||
<input value={openClawDashboardUrl} onChange={(event) => setOpenClawDashboardUrl(event.target.value)} 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)]" />
|
||||
</label>
|
||||
<label className="block space-y-2">
|
||||
<span className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">OpenShell Gateway</span>
|
||||
<input value={openshellGateway} onChange={(event) => setOpenshellGateway(event.target.value)} 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)]" />
|
||||
</label>
|
||||
</div>
|
||||
<label className="flex items-start gap-3 rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-3">
|
||||
<input type="checkbox" checked={exposePublicly} onChange={(event) => setExposePublicly(event.target.checked)} className="mt-0.5 h-4 w-4 accent-[var(--nvidia-green)]" />
|
||||
<span>
|
||||
<span className="block text-xs font-mono uppercase tracking-wider text-[var(--foreground)]">Controller UI is directly reachable</span>
|
||||
<span className="mt-1 block text-[11px] text-[var(--foreground-dim)]">Leave this off when you access the VPS through SSH tunnels, WireGuard, or Tailscale.</span>
|
||||
</span>
|
||||
</label>
|
||||
<button type="button" onClick={generateControllerPlan} disabled={controllerPlanning || !controllerHost.trim()} className="rounded-sm bg-[var(--nvidia-green)] px-4 py-2 text-xs font-mono uppercase tracking-wider text-black disabled:opacity-50">
|
||||
{controllerPlanning ? "Preparing..." : "Generate Launch Kit"}
|
||||
</button>
|
||||
{controllerMessage && <div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-3 text-sm text-[var(--foreground-dim)]">{controllerMessage}</div>}
|
||||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4">
|
||||
<h3 className="text-xs font-semibold uppercase tracking-wider text-[var(--foreground)]">Topology</h3>
|
||||
<div className="mt-3 space-y-2 text-xs text-[var(--foreground-dim)]">
|
||||
<p>Controller VPS: {controllerHost || "not set"}</p>
|
||||
<p>Sandbox host/gateway: {openshellGateway || "nemoclaw"}</p>
|
||||
<p>OpenClaw upstream: {openClawDashboardUrl}</p>
|
||||
</div>
|
||||
</div>
|
||||
{controllerPlan ? (
|
||||
<div className="space-y-4">
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<h3 className="text-xs font-semibold uppercase tracking-wider text-[var(--foreground)]">SSH Bootstrap</h3>
|
||||
<button type="button" onClick={() => copyText(controllerPlan.commands.ssh, "SSH bootstrap")} className="action-button px-3 py-1.5 text-[10px]">Copy</button>
|
||||
</div>
|
||||
<pre className="mt-3 max-h-72 overflow-auto whitespace-pre-wrap rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-3 text-[11px] leading-5 text-[var(--foreground-dim)]">{controllerPlan.commands.ssh}</pre>
|
||||
</div>
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<h3 className="text-xs font-semibold uppercase tracking-wider text-[var(--foreground)]">Controller Env</h3>
|
||||
<button type="button" onClick={() => copyText(controllerPlan.env, "Controller env")} className="action-button px-3 py-1.5 text-[10px]">Copy</button>
|
||||
</div>
|
||||
<pre className="mt-3 max-h-56 overflow-auto whitespace-pre-wrap rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-3 text-[11px] leading-5 text-[var(--foreground-dim)]">{controllerPlan.env}</pre>
|
||||
</div>
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4">
|
||||
<h3 className="text-xs font-semibold uppercase tracking-wider text-[var(--foreground)]">Readiness Checks</h3>
|
||||
<div className="mt-3 space-y-2">
|
||||
{controllerPlan.checks.map((check) => (
|
||||
<p key={check} className="text-xs text-[var(--foreground-dim)]">{check}</p>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4 text-sm text-[var(--foreground-dim)]">
|
||||
Enter the remote node details to generate a controller bootstrap command and matching environment block.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="panel overflow-hidden">
|
||||
<div className="border-b border-[var(--border-subtle)] p-5">
|
||||
<div className="flex items-center justify-between gap-4 max-md:flex-col max-md:items-start">
|
||||
|
||||
Reference in New Issue
Block a user