Integrate Docker NemoClaw and Hermes
This commit is contained in:
@@ -66,6 +66,8 @@ type NemoClawCreateCommand = {
|
||||
}
|
||||
|
||||
type CreateInferenceMode = "auto" | "vllm" | "nim"
|
||||
type CreateGpuMode = "none" | "auto" | "required"
|
||||
type NemoClawAgent = "openclaw" | "hermes"
|
||||
|
||||
type CreateInferenceSettings = {
|
||||
mode: CreateInferenceMode
|
||||
@@ -79,6 +81,13 @@ type NemoClawRegistryData = {
|
||||
defaultSandbox?: string | null
|
||||
}
|
||||
|
||||
function parseCreateGpuMode(body: any): CreateGpuMode {
|
||||
const raw = typeof body?.gpuMode === "string"
|
||||
? body.gpuMode
|
||||
: process.env.OPENSHELL_CONTROL_CREATE_GPU_MODE || "none"
|
||||
return raw === "auto" || raw === "required" ? raw : "none"
|
||||
}
|
||||
|
||||
function parseCreateInferenceSettings(body: any): CreateInferenceSettings {
|
||||
const raw = body?.createInference && typeof body.createInference === "object" ? body.createInference : {}
|
||||
const requestedMode = typeof raw.mode === "string" ? raw.mode : "vllm"
|
||||
@@ -124,13 +133,45 @@ function applyCreateInferenceEnv(env: NodeJS.ProcessEnv, settings: CreateInferen
|
||||
return settings
|
||||
}
|
||||
|
||||
function buildNemoClawCreateCommand(): NemoClawCreateCommand {
|
||||
function nemoClawGpuArgs(mode: CreateGpuMode) {
|
||||
if (mode === "required") return ["--gpu"]
|
||||
if (mode === "none") return ["--no-gpu"]
|
||||
return []
|
||||
}
|
||||
|
||||
function nemoClawAgentArgs(agent: NemoClawAgent) {
|
||||
return agent === "hermes" ? ["--agent", "hermes"] : []
|
||||
}
|
||||
|
||||
function isNemoClawOnboardBlueprint(blueprint: string) {
|
||||
return blueprint === "nemoclaw-blueprint" || blueprint === "nemoclaw-hermes"
|
||||
}
|
||||
|
||||
function nemoClawAgentForBlueprint(blueprint: string): NemoClawAgent {
|
||||
return blueprint === "nemoclaw-hermes" ? "hermes" : "openclaw"
|
||||
}
|
||||
|
||||
function openShellGpuArgs(mode: CreateGpuMode) {
|
||||
return mode === "required" ? ["--gpu"] : []
|
||||
}
|
||||
|
||||
function buildNemoClawCreateCommand(gpuMode: CreateGpuMode, agent: NemoClawAgent): NemoClawCreateCommand {
|
||||
if (NEMOCLAW_BIN && commandExists(NEMOCLAW_BIN)) {
|
||||
const args = ["onboard", "--non-interactive", "--recreate-sandbox", "--yes-i-accept-third-party-software"]
|
||||
const args = [
|
||||
"onboard",
|
||||
"--non-interactive",
|
||||
"--recreate-sandbox",
|
||||
"--yes-i-accept-third-party-software",
|
||||
...nemoClawAgentArgs(agent),
|
||||
...nemoClawGpuArgs(gpuMode),
|
||||
]
|
||||
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 (agent === "hermes") {
|
||||
throw new Error("Hermes sandbox creation requires the current NemoClaw CLI with --agent hermes support. Set NEMOCLAW_BIN in .env.local.")
|
||||
}
|
||||
if (NEMOCLAW_SETUP && commandExists(NEMOCLAW_SETUP)) {
|
||||
return { file: "/bin/bash", args: [NEMOCLAW_SETUP], mode: "legacy-setup" }
|
||||
}
|
||||
@@ -669,6 +710,14 @@ export async function GET() {
|
||||
source: "~/NemoClaw/nemoclaw-blueprint/blueprint.yaml",
|
||||
supportsTailscale: true,
|
||||
},
|
||||
{
|
||||
id: "nemoclaw-hermes",
|
||||
label: "Fresh Hermes Sandbox",
|
||||
description: "Bootstraps a Hermes Agent sandbox using NemoClaw's Hermes workflow.",
|
||||
type: "blueprint",
|
||||
source: "~/NemoClaw/agents/hermes/Dockerfile",
|
||||
supportsTailscale: false,
|
||||
},
|
||||
{
|
||||
id: "custom-sandbox",
|
||||
label: "New Custom Sandbox",
|
||||
@@ -698,17 +747,21 @@ export async function POST(request: Request) {
|
||||
const sandboxName = validateSandboxName(typeof body?.sandboxName === "string" ? body.sandboxName.trim() : "")
|
||||
const policy = body?.policy && typeof body.policy === "object" ? body.policy : null
|
||||
const enableTailscale = Boolean(body?.enableTailscale)
|
||||
const gpuMode = parseCreateGpuMode(body)
|
||||
const createInference = parseCreateInferenceSettings(body)
|
||||
console.log(`[sandbox/create] request:parsed sandbox=${sandboxName} blueprint=${blueprint} enableTailscale=${enableTailscale} inferenceMode=${createInference.mode} elapsedMs=${elapsedMs(requestStartedAt)}`)
|
||||
console.log(`[sandbox/create] request:parsed sandbox=${sandboxName} blueprint=${blueprint} enableTailscale=${enableTailscale} gpuMode=${gpuMode} inferenceMode=${createInference.mode} elapsedMs=${elapsedMs(requestStartedAt)}`)
|
||||
|
||||
if (!blueprint) {
|
||||
return NextResponse.json({ ok: false, error: "blueprint is required" }, { status: 400 })
|
||||
}
|
||||
|
||||
if (blueprint === "nemoclaw-blueprint") {
|
||||
const createCommand = buildNemoClawCreateCommand()
|
||||
if (isNemoClawOnboardBlueprint(blueprint)) {
|
||||
const agent = nemoClawAgentForBlueprint(blueprint)
|
||||
const isOpenClawAgent = agent === "openclaw"
|
||||
const createCommand = buildNemoClawCreateCommand(gpuMode, agent)
|
||||
const env: NodeJS.ProcessEnv = hostCommandEnv({
|
||||
NEMOCLAW_SANDBOX_NAME: sandboxName,
|
||||
NEMOCLAW_AGENT: agent,
|
||||
NEMOCLAW_NON_INTERACTIVE: "1",
|
||||
NEMOCLAW_RECREATE_SANDBOX: "1",
|
||||
NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE: "1",
|
||||
@@ -735,8 +788,10 @@ export async function POST(request: Request) {
|
||||
stdout: result.stdout,
|
||||
stderr: result.stderr,
|
||||
blueprint,
|
||||
agent,
|
||||
sandboxName,
|
||||
enableTailscale,
|
||||
gpuMode,
|
||||
createInference,
|
||||
}, { status: 500 })
|
||||
}
|
||||
@@ -748,25 +803,27 @@ export async function POST(request: Request) {
|
||||
error: "Sandbox readiness polling produced no verification result.",
|
||||
}
|
||||
const created = readiness.verified
|
||||
const execApprovalsRepair = created ? await repairOpenClawExecApprovalsFile(sandboxName).catch((error) => ({
|
||||
const execApprovalsRepair = created && isOpenClawAgent ? await repairOpenClawExecApprovalsFile(sandboxName).catch((error) => ({
|
||||
sandboxName,
|
||||
path: "/sandbox/.openclaw/exec-approvals.json",
|
||||
error: error instanceof Error ? error.message : "Failed to repair OpenClaw exec approvals file",
|
||||
})) : null
|
||||
const deviceApproval = created ? await approveOpenClawDeviceRequests(sandboxName) : null
|
||||
const deviceApproval = created && isOpenClawAgent ? await approveOpenClawDeviceRequests(sandboxName) : null
|
||||
console.log(
|
||||
`[sandbox/create] request:complete sandbox=${sandboxName} created=${created} readinessAttempts=${readiness.attempts} deviceApproval=${deviceApproval?.approved ?? false} elapsedMs=${elapsedMs(requestStartedAt)}`,
|
||||
`[sandbox/create] request:complete sandbox=${sandboxName} created=${created} agent=${agent} readinessAttempts=${readiness.attempts} deviceApproval=${deviceApproval?.approved ?? false} elapsedMs=${elapsedMs(requestStartedAt)}`,
|
||||
)
|
||||
|
||||
return NextResponse.json({
|
||||
ok: created,
|
||||
blueprint,
|
||||
agent,
|
||||
sandboxName,
|
||||
created,
|
||||
verified: verification.verified,
|
||||
verification,
|
||||
mode: "nemoclaw-blueprint",
|
||||
mode: blueprint,
|
||||
enableTailscale,
|
||||
gpuMode,
|
||||
createInference,
|
||||
createCommand,
|
||||
hostPath: HOST_PATH,
|
||||
@@ -780,9 +837,16 @@ export async function POST(request: Request) {
|
||||
stderr: result.stderr,
|
||||
note: created
|
||||
? appendNote(
|
||||
enableTailscale
|
||||
? "NemoClaw blueprint workflow completed with Tailscale-enabled prerequisites. Existing healthy OpenShell gateways are reused before any new gateway start is attempted."
|
||||
: "NemoClaw blueprint workflow completed in local/default mode. Existing healthy OpenShell gateways are reused before any new gateway start is attempted.",
|
||||
agent === "hermes"
|
||||
? "NemoClaw Hermes workflow completed. Hermes exposes an API endpoint from the sandbox rather than an OpenClaw browser dashboard."
|
||||
: enableTailscale
|
||||
? "NemoClaw blueprint workflow completed with Tailscale-enabled prerequisites. Existing healthy OpenShell gateways are reused before any new gateway start is attempted."
|
||||
: "NemoClaw blueprint workflow completed in local/default mode. Existing healthy OpenShell gateways are reused before any new gateway start is attempted.",
|
||||
gpuMode === "none"
|
||||
? "GPU passthrough was disabled for this create run."
|
||||
: gpuMode === "required"
|
||||
? "GPU passthrough was required for this create run."
|
||||
: "NemoClaw chose GPU passthrough automatically for this create run.",
|
||||
execApprovalsRepair && "note" in execApprovalsRepair ? execApprovalsRepair.note : false,
|
||||
execApprovalsRepair && "error" in execApprovalsRepair ? `OpenClaw exec approvals repair failed: ${execApprovalsRepair.error}` : false,
|
||||
deviceApproval?.note,
|
||||
@@ -798,7 +862,7 @@ export async function POST(request: Request) {
|
||||
CLICOLOR: "0",
|
||||
CLICOLOR_FORCE: "0",
|
||||
})
|
||||
const createAttempt = await runCreateCommandBounded(OPENSHELL_BIN, ["sandbox", "create", "--name", sandboxName], env, 15000)
|
||||
const createAttempt = await runCreateCommandBounded(OPENSHELL_BIN, ["sandbox", "create", "--name", sandboxName, ...openShellGpuArgs(gpuMode)], env, 15000)
|
||||
|
||||
if (createAttempt.completed && createAttempt.exitCode !== 0) {
|
||||
return NextResponse.json({
|
||||
@@ -808,6 +872,7 @@ export async function POST(request: Request) {
|
||||
stderr: createAttempt.stderr,
|
||||
blueprint,
|
||||
sandboxName,
|
||||
gpuMode,
|
||||
}, { status: 500 })
|
||||
}
|
||||
|
||||
@@ -836,6 +901,7 @@ export async function POST(request: Request) {
|
||||
verified: verification.verified,
|
||||
verification,
|
||||
mode: "custom-sandbox",
|
||||
gpuMode,
|
||||
stdout: createAttempt.stdout,
|
||||
stderr: createAttempt.stderr,
|
||||
createCommand: {
|
||||
@@ -859,6 +925,9 @@ export async function POST(request: Request) {
|
||||
: (policyPrepared
|
||||
? "Custom sandbox created. Policy draft is prepared, but applying it live should be a follow-up action."
|
||||
: "Custom sandbox created."),
|
||||
gpuMode === "required"
|
||||
? "GPU passthrough was requested for this create run."
|
||||
: false,
|
||||
execApprovalsRepair && "note" in execApprovalsRepair ? execApprovalsRepair.note : false,
|
||||
execApprovalsRepair && "error" in execApprovalsRepair ? `OpenClaw exec approvals repair failed: ${execApprovalsRepair.error}` : false,
|
||||
deviceApproval?.note,
|
||||
@@ -881,6 +950,7 @@ export async function POST(request: Request) {
|
||||
"create",
|
||||
"--name",
|
||||
sandboxName,
|
||||
...openShellGpuArgs(gpuMode),
|
||||
"--from",
|
||||
sourceImage,
|
||||
"--policy",
|
||||
@@ -921,6 +991,7 @@ export async function POST(request: Request) {
|
||||
verified: verification.verified,
|
||||
verification,
|
||||
mode: "redeploy-image",
|
||||
gpuMode,
|
||||
stdout: createAttempt.stdout,
|
||||
stderr: createAttempt.stderr,
|
||||
createCommand: {
|
||||
@@ -941,6 +1012,9 @@ export async function POST(request: Request) {
|
||||
note: created
|
||||
? appendNote(
|
||||
`Sandbox created by redeploying the running image from '${source.name}' instead of rebuilding it.`,
|
||||
gpuMode === "required"
|
||||
? "GPU passthrough was requested for this create run."
|
||||
: false,
|
||||
createAttempt.forcedReady
|
||||
? "The dashboard returned as soon as OpenShell reported the redeployed sandbox Ready."
|
||||
: false,
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { NextResponse } from "next/server"
|
||||
import { execFile } from "node:child_process"
|
||||
import { existsSync, readFileSync } from "node:fs"
|
||||
import { hostname, networkInterfaces } from "node:os"
|
||||
import path from "node:path"
|
||||
import { promisify } from "node:util"
|
||||
import { NEMOCLAW_BIN, NODE_BIN, OPENSHELL_BIN, hostCommandEnv } from "@/app/lib/hostCommands"
|
||||
import { resolveRuntimeAuthority } from "@/app/lib/runtimeAuthority"
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
const NEMOCLAW_REGISTRY_FILE = path.join(process.env.HOME || "/tmp", ".nemoclaw", "sandboxes.json")
|
||||
|
||||
type SandboxSummary = {
|
||||
id: string
|
||||
@@ -16,6 +19,7 @@ type SandboxSummary = {
|
||||
hasSshConfig: boolean
|
||||
source: "openshell"
|
||||
isDefault: boolean
|
||||
agent: string
|
||||
}
|
||||
|
||||
type NemoClawSummary = {
|
||||
@@ -26,6 +30,10 @@ type NemoClawSummary = {
|
||||
source: "nemoclaw-cli" | "none"
|
||||
}
|
||||
|
||||
type NemoClawRegistryData = {
|
||||
sandboxes?: Record<string, { name?: string; agent?: string | null }>
|
||||
}
|
||||
|
||||
type SandboxItem = {
|
||||
metadata: {
|
||||
name: string
|
||||
@@ -145,6 +153,24 @@ function buildNemoClawSummary(output: string | null, defaultSandboxNames: Set<st
|
||||
}
|
||||
}
|
||||
|
||||
function readNemoClawRegistry(): NemoClawRegistryData {
|
||||
try {
|
||||
return existsSync(NEMOCLAW_REGISTRY_FILE)
|
||||
? JSON.parse(readFileSync(NEMOCLAW_REGISTRY_FILE, "utf8"))
|
||||
: {}
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
function resolveSandboxAgent(name: string, id: string | null, registry: NemoClawRegistryData) {
|
||||
const entries = registry.sandboxes ?? {}
|
||||
const directEntry = entries[name] || (id ? entries[id] : undefined)
|
||||
const namedEntry = Object.values(entries).find((entry) => entry?.name === name || Boolean(id && entry?.name === id))
|
||||
const agent = directEntry?.agent || namedEntry?.agent
|
||||
return typeof agent === "string" && agent.trim() ? agent.trim() : "openclaw"
|
||||
}
|
||||
|
||||
async function execNemoclaw(args: string[]) {
|
||||
const env = hostCommandEnv({
|
||||
OPENSHELL_GATEWAY: process.env.OPENSHELL_GATEWAY || "nemoclaw",
|
||||
@@ -189,7 +215,7 @@ function readHostIdentity() {
|
||||
return { hostname: hostname(), address: "127.0.0.1", interface: "lo0" }
|
||||
}
|
||||
|
||||
async function readSandbox(name: string, defaultSandboxNames: Set<string>): Promise<{ summary: SandboxSummary; pod: SandboxItem }> {
|
||||
async function readSandbox(name: string, defaultSandboxNames: Set<string>, registry: NemoClawRegistryData): Promise<{ summary: SandboxSummary; pod: SandboxItem }> {
|
||||
try {
|
||||
const [{ stdout: detailsStdout }, { stdout: sshStdout }] = await Promise.all([
|
||||
execOpenShell(["sandbox", "get", name]),
|
||||
@@ -203,6 +229,7 @@ async function readSandbox(name: string, defaultSandboxNames: Set<string>): Prom
|
||||
const sshConfig = sshStdout.trim()
|
||||
const sshHostAlias = parseSshHostAlias(sshConfig, sandboxName)
|
||||
const isDefault = defaultSandboxNames.has(sandboxName)
|
||||
const agent = resolveSandboxAgent(sandboxName, sandboxId, registry)
|
||||
|
||||
return {
|
||||
summary: {
|
||||
@@ -214,6 +241,7 @@ async function readSandbox(name: string, defaultSandboxNames: Set<string>): Prom
|
||||
hasSshConfig: Boolean(sshConfig),
|
||||
source: "openshell",
|
||||
isDefault,
|
||||
agent,
|
||||
},
|
||||
pod: {
|
||||
metadata: {
|
||||
@@ -223,6 +251,7 @@ async function readSandbox(name: string, defaultSandboxNames: Set<string>): Prom
|
||||
"nemoclaw.ai/sandbox-name": sandboxName,
|
||||
...(sandboxId ? { "nemoclaw.ai/sandbox-id": sandboxId } : {}),
|
||||
...(isDefault ? { "nemoclaw.ai/default": "true" } : {}),
|
||||
"nemoclaw.ai/agent": agent,
|
||||
},
|
||||
},
|
||||
spec: {
|
||||
@@ -245,6 +274,7 @@ async function readSandbox(name: string, defaultSandboxNames: Set<string>): Prom
|
||||
} catch (error) {
|
||||
const sandboxName = name
|
||||
const isDefault = defaultSandboxNames.has(sandboxName)
|
||||
const agent = resolveSandboxAgent(sandboxName, sandboxName, registry)
|
||||
return {
|
||||
summary: {
|
||||
id: sandboxName,
|
||||
@@ -255,6 +285,7 @@ async function readSandbox(name: string, defaultSandboxNames: Set<string>): Prom
|
||||
hasSshConfig: false,
|
||||
source: "openshell",
|
||||
isDefault,
|
||||
agent,
|
||||
},
|
||||
pod: {
|
||||
metadata: {
|
||||
@@ -264,6 +295,7 @@ async function readSandbox(name: string, defaultSandboxNames: Set<string>): Prom
|
||||
"nemoclaw.ai/sandbox-name": sandboxName,
|
||||
"nemoclaw.ai/sandbox-id": sandboxName,
|
||||
...(isDefault ? { "nemoclaw.ai/default": "true" } : {}),
|
||||
"nemoclaw.ai/agent": agent,
|
||||
},
|
||||
},
|
||||
spec: {
|
||||
@@ -297,7 +329,8 @@ export async function GET() {
|
||||
])
|
||||
: [null, null]
|
||||
const defaultSandboxNames = parseDefaultSandboxNames(nemoclawListResult?.stdout ?? "")
|
||||
const results = await Promise.all(names.map((name) => readSandbox(name, defaultSandboxNames)))
|
||||
const registry = readNemoClawRegistry()
|
||||
const results = await Promise.all(names.map((name) => readSandbox(name, defaultSandboxNames, registry)))
|
||||
const sandboxes = results.map((result) => result.summary)
|
||||
const items = results.map((result) => result.pod)
|
||||
const nemoclaw = buildNemoClawSummary(nemoclawStatusResult?.stdout ?? null, defaultSandboxNames)
|
||||
|
||||
@@ -8,6 +8,7 @@ type EndpointTls = "" | "terminate" | "passthrough"
|
||||
type EndpointEnforcement = "" | "enforce" | "audit"
|
||||
type EndpointAccess = "" | "read-only" | "read-write" | "full"
|
||||
type CreateInferenceMode = "auto" | "vllm" | "nim"
|
||||
type CreateGpuMode = "none" | "auto" | "required"
|
||||
|
||||
interface NetworkRule { method: string; path: string }
|
||||
interface NetworkEndpoint { host: string; port: string; protocol: EndpointProtocol; tls: EndpointTls; enforcement: EndpointEnforcement; access: EndpointAccess; rules: NetworkRule[] }
|
||||
@@ -88,6 +89,7 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre
|
||||
const [selectedBlueprint, setSelectedBlueprint] = useState<string>('redeploy-image')
|
||||
const [sandboxName, setSandboxName] = useState<string>('')
|
||||
const [enableTailscale, setEnableTailscale] = useState<boolean>(false)
|
||||
const [createGpuMode, setCreateGpuMode] = useState<CreateGpuMode>("none")
|
||||
const [createInferenceMode, setCreateInferenceMode] = useState<CreateInferenceMode>("vllm")
|
||||
const [createInferenceModel, setCreateInferenceModel] = useState<string>("")
|
||||
const [createNvidiaApiKey, setCreateNvidiaApiKey] = useState<string>("")
|
||||
@@ -126,6 +128,7 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre
|
||||
const assembledPolicy = useMemo(() => ({ ...policy, network_policies: blocksToPolicy(blocks) }), [policy, blocks])
|
||||
const activePreset = selectedPreset ? getSecurityPreset(selectedPreset) : null
|
||||
const activeBlueprint = blueprints.find((bp) => bp.id === selectedBlueprint)
|
||||
const isNemoClawOnboardBlueprint = selectedBlueprint === 'nemoclaw-blueprint' || selectedBlueprint === 'nemoclaw-hermes'
|
||||
|
||||
function applyPreset(presetId: SecurityPresetId) {
|
||||
const preset = getSecurityPreset(presetId); if (!preset) return
|
||||
@@ -143,7 +146,7 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre
|
||||
model: createInferenceModel.trim(),
|
||||
apiKey: createInferenceMode === 'nim' ? createNvidiaApiKey.trim() : '',
|
||||
}
|
||||
const res = await fetch('/api/sandbox/create', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ blueprint: selectedBlueprint, sandboxName: sandboxName.trim(), enableTailscale, createInference, policy: assembledPolicy, preset: selectedPreset || null }) })
|
||||
const res = await fetch('/api/sandbox/create', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ blueprint: selectedBlueprint, sandboxName: sandboxName.trim(), enableTailscale, gpuMode: createGpuMode, createInference, policy: assembledPolicy, preset: selectedPreset || null }) })
|
||||
const data = await res.json()
|
||||
if (!res.ok) throw new Error([data.error, data.verification?.summary, data.verification?.error, data.stdout, data.stderr].filter(Boolean).join('\n\n'))
|
||||
const createdSandboxId = data.verification?.details?.id || data.verification?.details?.name || data.sandboxName
|
||||
@@ -216,7 +219,27 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-xs uppercase tracking-wider text-[var(--foreground-dim)]">Sandbox Name<FieldHelp text="Lowercase letters, numbers, and hyphens only." /></label>
|
||||
<input value={sandboxName} onChange={(e) => setSandboxName(e.target.value)} placeholder={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)} placeholder={selectedBlueprint === 'nemoclaw-hermes' ? 'my-hermes' : 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)]" />
|
||||
</div>
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-4 space-y-4">
|
||||
<div>
|
||||
<h6 className="text-xs font-semibold uppercase tracking-wider text-[var(--foreground)]">GPU Passthrough</h6>
|
||||
<p className="mt-1 text-xs text-[var(--foreground-dim)]">Choose whether new sandboxes should request NVIDIA GPU devices.</p>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 gap-3 md:grid-cols-3">
|
||||
<label className={`flex items-start gap-3 rounded-sm border p-3 text-sm text-[var(--foreground)] ${createGpuMode === 'none' ? 'border-[var(--nvidia-green)] bg-[rgba(118,185,0,0.08)]' : 'border-[var(--border-subtle)] bg-[var(--background-tertiary)]'}`}>
|
||||
<input type="radio" name="create-gpu-mode" checked={createGpuMode === 'none'} onChange={() => setCreateGpuMode('none')} className="mt-0.5 h-4 w-4 accent-[var(--nvidia-green)]" />
|
||||
<span><span className="block text-xs font-mono uppercase tracking-wider">No GPU</span><span className="mt-1 block text-[11px] text-[var(--foreground-dim)]">Passes --no-gpu to NemoClaw and avoids CDI setup.</span></span>
|
||||
</label>
|
||||
<label className={`flex items-start gap-3 rounded-sm border p-3 text-sm text-[var(--foreground)] ${createGpuMode === 'auto' ? 'border-[var(--nvidia-green)] bg-[rgba(118,185,0,0.08)]' : 'border-[var(--border-subtle)] bg-[var(--background-tertiary)]'}`}>
|
||||
<input type="radio" name="create-gpu-mode" checked={createGpuMode === 'auto'} onChange={() => setCreateGpuMode('auto')} className="mt-0.5 h-4 w-4 accent-[var(--nvidia-green)]" />
|
||||
<span><span className="block text-xs font-mono uppercase tracking-wider">Auto</span><span className="mt-1 block text-[11px] text-[var(--foreground-dim)]">Let NemoClaw/OpenShell infer GPU intent.</span></span>
|
||||
</label>
|
||||
<label className={`flex items-start gap-3 rounded-sm border p-3 text-sm text-[var(--foreground)] ${createGpuMode === 'required' ? 'border-[var(--nvidia-green)] bg-[rgba(118,185,0,0.08)]' : 'border-[var(--border-subtle)] bg-[var(--background-tertiary)]'}`}>
|
||||
<input type="radio" name="create-gpu-mode" checked={createGpuMode === 'required'} onChange={() => setCreateGpuMode('required')} className="mt-0.5 h-4 w-4 accent-[var(--nvidia-green)]" />
|
||||
<span><span className="block text-xs font-mono uppercase tracking-wider">Require GPU</span><span className="mt-1 block text-[11px] text-[var(--foreground-dim)]">Requires NVIDIA CDI devices or gateway GPU support.</span></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
{selectedBlueprint === 'redeploy-image' && (
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-4">
|
||||
@@ -229,7 +252,7 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre
|
||||
</label>
|
||||
)}
|
||||
{enableTailscale && <div className="rounded-sm border border-amber-500/40 bg-amber-500/10 p-3 text-sm text-amber-300">Tailscale-enabled creation requires NVIDIA_API_KEY in the dashboard process environment.</div>}
|
||||
{selectedBlueprint === 'nemoclaw-blueprint' && <div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-4 space-y-4">
|
||||
{isNemoClawOnboardBlueprint && <div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-4 space-y-4">
|
||||
<div>
|
||||
<h6 className="text-xs font-semibold uppercase tracking-wider text-[var(--foreground)]">Inference at Create</h6>
|
||||
<p className="mt-1 text-xs text-[var(--foreground-dim)]">Choose the provider NemoClaw should use while onboarding this sandbox.</p>
|
||||
|
||||
+209
-51
@@ -5,6 +5,7 @@ import ConfigurationPanel from './ConfigurationPanel'
|
||||
import SandboxArchivePanel from './SandboxArchivePanel'
|
||||
import SandboxFilesPanel from './SandboxFilesPanel'
|
||||
import SandboxInferencePanel from './SandboxInferencePanel'
|
||||
import { buildOperatorTerminalRoute } from '../lib/dashboardSession'
|
||||
import type { NemoClawSummary, SandboxInventoryItem } from '../hooks/useSandboxInventory'
|
||||
|
||||
interface TelemetryData {
|
||||
@@ -25,6 +26,7 @@ interface SandboxListProps {
|
||||
onSandboxSelect: (id: string | null) => void
|
||||
isDestroyMode: boolean
|
||||
onInventoryRefresh: () => Promise<SandboxInventoryItem[]>
|
||||
dashboardSessionId: string
|
||||
}
|
||||
|
||||
type DrawerKey = 'operations' | 'files' | 'inference' | 'policy' | 'archive' | 'mcp'
|
||||
@@ -55,6 +57,13 @@ type PermissionFeed = {
|
||||
rejectedCount?: number
|
||||
}
|
||||
|
||||
type DismissedPermissionAlerts = Record<string, string[]>
|
||||
|
||||
const DISMISSED_PERMISSION_ALERTS_STORAGE_KEY = 'openshell-control-dismissed-permission-alerts'
|
||||
const DISMISS_PERMISSION_VALUE = '__dismiss_permission_alerts__'
|
||||
const OPENCLAW_SANDBOX_LOGO = '/sandbox-logos/openclaw.svg'
|
||||
const HERMES_SANDBOX_LOGO = '/sandbox-logos/hermes.png'
|
||||
|
||||
function renderDashboardTruthMessage(data: any) {
|
||||
if (data.reachable) return 'OpenClaw dashboard opened in a new tab.'
|
||||
return 'OpenClaw dashboard is not reachable from this host right now.'
|
||||
@@ -68,6 +77,74 @@ function openDashboardUrl(url: string, openInNewTab: boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
function displaySandboxAgent(agent?: string) {
|
||||
if (agent === 'hermes') return 'Hermes'
|
||||
return 'OpenClaw'
|
||||
}
|
||||
|
||||
function SandboxTypeLogo({ agent }: { agent?: string }) {
|
||||
const isHermes = agent === 'hermes'
|
||||
const label = isHermes ? 'Hermes sandbox' : 'OpenClaw sandbox'
|
||||
const logoSrc = isHermes ? HERMES_SANDBOX_LOGO : OPENCLAW_SANDBOX_LOGO
|
||||
return (
|
||||
<span
|
||||
aria-label={label}
|
||||
title={label}
|
||||
className={`flex h-8 w-8 shrink-0 items-center justify-center rounded-md border shadow-inner ${
|
||||
isHermes
|
||||
? 'border-sky-300/60 bg-sky-500/15'
|
||||
: 'border-rose-300/60 bg-rose-500/15'
|
||||
}`}
|
||||
>
|
||||
<span aria-hidden="true" className="h-6 w-6 bg-contain bg-center bg-no-repeat" style={{ backgroundImage: `url(${logoSrc})` }} />
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
function normalizeDismissedPermissionAlerts(value: unknown): DismissedPermissionAlerts {
|
||||
if (!value || typeof value !== 'object' || Array.isArray(value)) return {}
|
||||
return Object.entries(value as Record<string, unknown>).reduce<DismissedPermissionAlerts>((normalized, [sandboxId, chunks]) => {
|
||||
if (Array.isArray(chunks)) {
|
||||
const ids = chunks.filter((chunk): chunk is string => typeof chunk === 'string' && chunk.length > 0)
|
||||
if (ids.length > 0) normalized[sandboxId] = Array.from(new Set(ids))
|
||||
}
|
||||
return normalized
|
||||
}, {})
|
||||
}
|
||||
|
||||
function loadDismissedPermissionAlerts(): DismissedPermissionAlerts {
|
||||
if (typeof window === 'undefined') return {}
|
||||
try {
|
||||
return normalizeDismissedPermissionAlerts(JSON.parse(window.localStorage.getItem(DISMISSED_PERMISSION_ALERTS_STORAGE_KEY) || '{}'))
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
function saveDismissedPermissionAlerts(alerts: DismissedPermissionAlerts) {
|
||||
if (typeof window === 'undefined') return
|
||||
window.localStorage.setItem(DISMISSED_PERMISSION_ALERTS_STORAGE_KEY, JSON.stringify(alerts))
|
||||
}
|
||||
|
||||
function dismissedPermissionSet(alerts: DismissedPermissionAlerts, sandbox: SandboxInventoryItem) {
|
||||
return new Set([...(alerts[sandbox.id] || []), ...(alerts[sandbox.name] || [])])
|
||||
}
|
||||
|
||||
function visiblePendingRequests(feed: PermissionFeed | undefined, sandbox: SandboxInventoryItem, alerts: DismissedPermissionAlerts) {
|
||||
const dismissed = dismissedPermissionSet(alerts, sandbox)
|
||||
return (feed?.pending || []).filter((request) => !request.chunkId || !dismissed.has(request.chunkId))
|
||||
}
|
||||
|
||||
function permissionFeedNeedsAttention(feed: PermissionFeed | undefined, sandbox: SandboxInventoryItem, alerts: DismissedPermissionAlerts) {
|
||||
const latestStatus = feed?.latest?.status || ''
|
||||
const latestChunkId = feed?.latest?.chunkId || ''
|
||||
const dismissed = dismissedPermissionSet(alerts, sandbox)
|
||||
return Boolean(
|
||||
visiblePendingRequests(feed, sandbox, alerts).length > 0 ||
|
||||
(/pending|fail|error|unavailable/i.test(latestStatus) && (!latestChunkId || !dismissed.has(latestChunkId))),
|
||||
)
|
||||
}
|
||||
|
||||
function DrawerSection({
|
||||
title,
|
||||
summary,
|
||||
@@ -120,11 +197,13 @@ export default function SandboxList({
|
||||
onSandboxSelect,
|
||||
isDestroyMode,
|
||||
onInventoryRefresh,
|
||||
dashboardSessionId,
|
||||
}: SandboxListProps) {
|
||||
const [dashboardMessage, setDashboardMessage] = useState<string>('')
|
||||
const [restartInProgress, setRestartInProgress] = useState(false)
|
||||
const [permissionMessage, setPermissionMessage] = useState('')
|
||||
const [permissionFeeds, setPermissionFeeds] = useState<Record<string, PermissionFeed>>({})
|
||||
const [dismissedPermissionAlerts, setDismissedPermissionAlerts] = useState<DismissedPermissionAlerts>(() => loadDismissedPermissionAlerts())
|
||||
const [grantingSandboxId, setGrantingSandboxId] = useState<string | null>(null)
|
||||
const [mcpServers, setMcpServers] = useState<McpServerAccess[]>([])
|
||||
const [mcpMessage, setMcpMessage] = useState('')
|
||||
@@ -244,6 +323,16 @@ export default function SandboxList({
|
||||
const allowedMcpServersForSandbox = (sandbox: SandboxInventoryItem) => (
|
||||
mcpServers.filter((server) => sandboxCanAccessMcpServer(sandbox, server))
|
||||
)
|
||||
const selectedSandboxIsHermes = selectedSandbox?.agent === 'hermes'
|
||||
|
||||
const connectToHermes = (sandbox: SandboxInventoryItem) => {
|
||||
const route = buildOperatorTerminalRoute({
|
||||
sandboxId: sandbox.name,
|
||||
dashboardSessionId,
|
||||
launch: 'hermes',
|
||||
})
|
||||
window.open(route, '_blank', 'noopener,noreferrer')
|
||||
}
|
||||
|
||||
const updateMcpServerAccess = async (
|
||||
server: McpServerAccess,
|
||||
@@ -313,6 +402,41 @@ export default function SandboxList({
|
||||
}, `${server.name} revoked from ${sandbox.name}.`).then(() => syncMcpManifest(sandbox))
|
||||
}
|
||||
|
||||
const dismissPermissionAlerts = (sandbox: SandboxInventoryItem, chunkId?: string) => {
|
||||
const feed = permissionFeeds[sandbox.id]
|
||||
const visibleIds = visiblePendingRequests(feed, sandbox, dismissedPermissionAlerts)
|
||||
.map((request) => request.chunkId)
|
||||
.filter(Boolean)
|
||||
const idsToDismiss = chunkId ? [chunkId] : visibleIds
|
||||
|
||||
if (idsToDismiss.length === 0) {
|
||||
setPermissionMessage(`No permission alerts to hide for ${sandbox.name}.`)
|
||||
return
|
||||
}
|
||||
|
||||
setDismissedPermissionAlerts((current) => {
|
||||
const existing = new Set(current[sandbox.id] || [])
|
||||
for (const id of idsToDismiss) existing.add(id)
|
||||
const next = { ...current, [sandbox.id]: Array.from(existing) }
|
||||
saveDismissedPermissionAlerts(next)
|
||||
return next
|
||||
})
|
||||
setPermissionMessage(idsToDismiss.length === 1 ? `Permission alert hidden for ${sandbox.name}.` : `Permission alerts hidden for ${sandbox.name}.`)
|
||||
}
|
||||
|
||||
const clearDismissedPermissionAlert = (sandbox: SandboxInventoryItem, chunkId: string) => {
|
||||
setDismissedPermissionAlerts((current) => {
|
||||
const existing = current[sandbox.id]
|
||||
if (!existing?.includes(chunkId)) return current
|
||||
const remaining = existing.filter((id) => id !== chunkId)
|
||||
const next = { ...current }
|
||||
if (remaining.length > 0) next[sandbox.id] = remaining
|
||||
else delete next[sandbox.id]
|
||||
saveDismissedPermissionAlerts(next)
|
||||
return next
|
||||
})
|
||||
}
|
||||
|
||||
const resolvePermissionRequest = async (sandbox: SandboxInventoryItem, action: 'approve' | 'reject', chunkId: string) => {
|
||||
if (!chunkId) return
|
||||
try {
|
||||
@@ -328,6 +452,7 @@ export default function SandboxList({
|
||||
if (data.result?.feed) {
|
||||
setPermissionFeeds((current) => ({ ...current, [sandbox.id]: data.result.feed }))
|
||||
}
|
||||
clearDismissedPermissionAlert(sandbox, chunkId)
|
||||
setPermissionMessage(data.note || `Network request ${action === 'approve' ? 'approved' : 'rejected'} for ${sandbox.name}.`)
|
||||
} catch (error) {
|
||||
setPermissionMessage(error instanceof Error ? error.message : 'Failed to resolve permission request')
|
||||
@@ -384,11 +509,13 @@ export default function SandboxList({
|
||||
>
|
||||
<div className="mb-3 flex items-start justify-between gap-3">
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<SandboxTypeLogo agent={sandbox.agent} />
|
||||
{(() => {
|
||||
const feed = permissionFeeds[sandbox.id]
|
||||
const needsAttention = Boolean((feed?.pendingCount || 0) > 0 || /pending|fail|error|unavailable/i.test(feed?.latest?.status || ''))
|
||||
const visiblePending = visiblePendingRequests(feed, sandbox, dismissedPermissionAlerts)
|
||||
const needsAttention = permissionFeedNeedsAttention(feed, sandbox, dismissedPermissionAlerts)
|
||||
return needsAttention ? (
|
||||
<span className="inline-flex h-5 w-5 items-center justify-center rounded-full bg-amber-400 text-black animate-pulse" title={`Network permission: ${feed?.pendingCount || 0} pending`}>
|
||||
<span className="inline-flex h-5 w-5 items-center justify-center rounded-full bg-amber-400 text-black animate-pulse" title={`Network permission: ${visiblePending.length} pending`}>
|
||||
<svg className="h-3.5 w-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M12 8v5m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z" />
|
||||
</svg>
|
||||
@@ -441,6 +568,7 @@ export default function SandboxList({
|
||||
|
||||
<div className="space-y-1.5">
|
||||
{([
|
||||
['Agent', displaySandboxAgent(sandbox.agent), '120px'],
|
||||
['Attach Target', sandbox.ip, '180px'],
|
||||
['Namespace', sandbox.namespace, '120px'],
|
||||
['Host Alias', sandbox.sshHostAlias || 'N/A', '140px'],
|
||||
@@ -454,30 +582,43 @@ export default function SandboxList({
|
||||
</div>
|
||||
</button>
|
||||
<div className="border-t border-[var(--border-subtle)] p-3">
|
||||
<select
|
||||
value=""
|
||||
disabled={grantingSandboxId === sandbox.id}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
onChange={(event) => {
|
||||
const value = event.target.value
|
||||
event.currentTarget.value = ''
|
||||
resolvePermissionRequest(sandbox, 'approve', value)
|
||||
}}
|
||||
className="field-control w-full px-3 py-2 font-mono text-xs uppercase tracking-wider"
|
||||
>
|
||||
<option value="">
|
||||
{grantingSandboxId === sandbox.id
|
||||
? 'Granting...'
|
||||
: (permissionFeeds[sandbox.id]?.pendingCount || 0) > 0
|
||||
? 'Grant Permission'
|
||||
: 'No Permission Requests'}
|
||||
</option>
|
||||
{(permissionFeeds[sandbox.id]?.pending || []).map((request) => (
|
||||
<option key={request.chunkId} value={request.chunkId}>
|
||||
{(request.endpoints[0] || request.rule || request.chunkId).slice(0, 46)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{(() => {
|
||||
const feed = permissionFeeds[sandbox.id]
|
||||
const visiblePending = visiblePendingRequests(feed, sandbox, dismissedPermissionAlerts)
|
||||
return (
|
||||
<select
|
||||
value=""
|
||||
disabled={grantingSandboxId === sandbox.id}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
onChange={(event) => {
|
||||
const value = event.target.value
|
||||
event.currentTarget.value = ''
|
||||
if (value === DISMISS_PERMISSION_VALUE) {
|
||||
dismissPermissionAlerts(sandbox)
|
||||
return
|
||||
}
|
||||
resolvePermissionRequest(sandbox, 'approve', value)
|
||||
}}
|
||||
className="field-control w-full px-3 py-2 font-mono text-xs uppercase tracking-wider"
|
||||
>
|
||||
<option value="">
|
||||
{grantingSandboxId === sandbox.id
|
||||
? 'Granting...'
|
||||
: visiblePending.length > 0
|
||||
? 'Grant Permission'
|
||||
: 'No Permission Requests'}
|
||||
</option>
|
||||
{visiblePending.length > 0 ? (
|
||||
<option value={DISMISS_PERMISSION_VALUE}>Do Nothing</option>
|
||||
) : null}
|
||||
{visiblePending.map((request) => (
|
||||
<option key={request.chunkId} value={request.chunkId}>
|
||||
{(request.endpoints[0] || request.rule || request.chunkId).slice(0, 46)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
)
|
||||
})()}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
@@ -493,36 +634,45 @@ export default function SandboxList({
|
||||
<>
|
||||
<DrawerSection
|
||||
title={`${selectedSandbox.name} - Operations`}
|
||||
summary="Dashboard, terminal, restart, refresh, and live telemetry."
|
||||
summary={selectedSandboxIsHermes ? "Terminal, restart, refresh, and live telemetry." : "Dashboard, terminal, restart, refresh, and live telemetry."}
|
||||
open={openDrawers.operations}
|
||||
onToggle={() => toggleDrawer('operations')}
|
||||
>
|
||||
<div className="space-y-6">
|
||||
<div className="flex flex-wrap items-center gap-3 max-sm:[&>button]:w-full">
|
||||
<button
|
||||
onClick={async () => {
|
||||
try {
|
||||
const searchParams = new URLSearchParams()
|
||||
searchParams.set('sandboxId', selectedSandbox.name)
|
||||
searchParams.set('inventoryCount', String(sandboxes.length))
|
||||
const res = await fetch(`/api/openshell/dashboard/open?${searchParams.toString()}`)
|
||||
const data = await res.json()
|
||||
setDashboardMessage(renderDashboardTruthMessage(data))
|
||||
if (data.reachable && data.launchUrl) {
|
||||
openDashboardUrl(data.launchUrl, data.openInNewTab)
|
||||
} else if (data.reachable && data.proxiedUrl) {
|
||||
openDashboardUrl(data.proxiedUrl, data.openInNewTab)
|
||||
} else if (data.reachable && data.dashboardUrl && !data.loopbackOnly) {
|
||||
openDashboardUrl(data.dashboardUrl, data.openInNewTab)
|
||||
{!selectedSandboxIsHermes ? (
|
||||
<button
|
||||
onClick={async () => {
|
||||
try {
|
||||
const searchParams = new URLSearchParams()
|
||||
searchParams.set('sandboxId', selectedSandbox.name)
|
||||
searchParams.set('inventoryCount', String(sandboxes.length))
|
||||
const res = await fetch(`/api/openshell/dashboard/open?${searchParams.toString()}`)
|
||||
const data = await res.json()
|
||||
setDashboardMessage(renderDashboardTruthMessage(data))
|
||||
if (data.reachable && data.launchUrl) {
|
||||
openDashboardUrl(data.launchUrl, data.openInNewTab)
|
||||
} else if (data.reachable && data.proxiedUrl) {
|
||||
openDashboardUrl(data.proxiedUrl, data.openInNewTab)
|
||||
} else if (data.reachable && data.dashboardUrl && !data.loopbackOnly) {
|
||||
openDashboardUrl(data.dashboardUrl, data.openInNewTab)
|
||||
}
|
||||
} catch (error) {
|
||||
setDashboardMessage('Failed to resolve OpenClaw Dashboard endpoint.')
|
||||
}
|
||||
} catch (error) {
|
||||
setDashboardMessage('Failed to resolve OpenClaw Dashboard endpoint.')
|
||||
}
|
||||
}}
|
||||
className="action-button px-3 py-2"
|
||||
>
|
||||
Start OpenClaw Gateway Dashboard
|
||||
</button>
|
||||
}}
|
||||
className="action-button px-3 py-2"
|
||||
>
|
||||
Start OpenClaw Gateway Dashboard
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
onClick={() => connectToHermes(selectedSandbox)}
|
||||
className="action-button px-3 py-2"
|
||||
>
|
||||
Connect to Hermes
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
onClick={restartSandbox}
|
||||
disabled={restartInProgress}
|
||||
@@ -679,7 +829,7 @@ export default function SandboxList({
|
||||
<div className="space-y-4">
|
||||
{(() => {
|
||||
const feed = permissionFeeds[selectedSandbox.id]
|
||||
const pending = feed?.pending || []
|
||||
const pending = visiblePendingRequests(feed, selectedSandbox, dismissedPermissionAlerts)
|
||||
if (pending.length === 0) {
|
||||
return (
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4 text-xs text-[var(--foreground-dim)]">
|
||||
@@ -724,6 +874,14 @@ export default function SandboxList({
|
||||
>
|
||||
Reject
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
disabled={grantingSandboxId === selectedSandbox.id}
|
||||
onClick={() => dismissPermissionAlerts(selectedSandbox, request.chunkId)}
|
||||
className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] px-3 py-2 text-xs font-mono uppercase tracking-wider text-[var(--foreground-dim)] disabled:opacity-50"
|
||||
>
|
||||
Do Nothing
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -11,6 +11,7 @@ export interface SandboxInventoryItem {
|
||||
ready: boolean
|
||||
sshHostAlias?: string
|
||||
isDefault?: boolean
|
||||
agent?: string
|
||||
}
|
||||
|
||||
export interface NemoClawSummary {
|
||||
@@ -48,6 +49,7 @@ function mapSandboxSummary(sandbox: any): SandboxInventoryItem {
|
||||
ready: status === 'running',
|
||||
sshHostAlias: sandbox.sshHostAlias || undefined,
|
||||
isDefault: Boolean(sandbox.isDefault),
|
||||
agent: typeof sandbox.agent === 'string' && sandbox.agent ? sandbox.agent : 'openclaw',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +64,7 @@ function mapPodItem(pod: any): SandboxInventoryItem {
|
||||
ready: pod.status?.conditions?.find((c: any) => c.type === 'Ready')?.status === 'True',
|
||||
sshHostAlias: pod.status?.podIP || undefined,
|
||||
isDefault: pod.metadata?.labels?.['nemoclaw.ai/default'] === 'true',
|
||||
agent: pod.metadata?.labels?.['nemoclaw.ai/agent'] || 'openclaw',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,12 +78,16 @@ export function persistDashboardSessionState(session: DashboardSessionState) {
|
||||
export function buildOperatorTerminalRoute(params: {
|
||||
sandboxId?: string | null
|
||||
dashboardSessionId: string
|
||||
launch?: 'hermes' | null
|
||||
}) {
|
||||
const searchParams = new URLSearchParams()
|
||||
if (params.sandboxId) {
|
||||
searchParams.set('sandboxId', params.sandboxId)
|
||||
}
|
||||
searchParams.set('dashboardSessionId', params.dashboardSessionId)
|
||||
if (params.launch) {
|
||||
searchParams.set('launch', params.launch)
|
||||
}
|
||||
const query = searchParams.toString()
|
||||
return query ? `/operator-terminal?${query}` : '/operator-terminal'
|
||||
}
|
||||
|
||||
@@ -59,9 +59,39 @@ const defaultAlias = (sandboxId: string | null) => `ssh openshell-${sandboxId ||
|
||||
const defaultFallback = (sandboxId: string | null) => `ssh openshell-${sandboxId || 'my-assistant'}`
|
||||
const defaultLoginShell = (sandboxId: string | null) => `env PATH=$HOME/.local/bin:$PATH bash -l -c 'ssh openshell-${sandboxId || 'my-assistant'}'`
|
||||
const DEFAULT_SHELL_HINT = 'If your non-interactive shell misses local tooling, retry from a login shell or prepend PATH=$HOME/.local/bin:$PATH before ssh.'
|
||||
|
||||
function shellQuote(value: string) {
|
||||
return `'${value.replace(/'/g, `'"'"'`)}'`
|
||||
}
|
||||
|
||||
function escapeRegExp(value: string) {
|
||||
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||
}
|
||||
|
||||
function buildHermesTerminalConnectCommand(sandboxId: string) {
|
||||
const target = shellQuote(sandboxId)
|
||||
const alias = shellQuote(`openshell-${sandboxId}`)
|
||||
const message = shellQuote(`[OpenShell Control] Connecting to Hermes sandbox ${sandboxId}...`)
|
||||
return [
|
||||
`printf '\\n%s\\n' ${message}`,
|
||||
`if command -v nemohermes >/dev/null 2>&1; then nemohermes ${target} connect; elif command -v nemoclaw >/dev/null 2>&1; then nemoclaw ${target} connect; else ssh ${alias}; fi`,
|
||||
].join('; ')
|
||||
}
|
||||
|
||||
const HERMES_AGENT_COMMAND = "if command -v hermes >/dev/null 2>&1; then hermes; else echo 'Hermes CLI not found in this shell. Check that the terminal is attached to a Hermes sandbox.' >&2; fi"
|
||||
|
||||
function isHermesAttachReadyOutput(output: string, sandboxId: string) {
|
||||
const escapedSandboxId = escapeRegExp(sandboxId)
|
||||
return (
|
||||
new RegExp(`(?:^|\\n)sandbox@${escapedSandboxId}:[^\\n]*[$#]\\s*$`).test(output) ||
|
||||
/(?:^|\n)sandbox@[^:\s]+:[^\n]*[$#]\s*$/.test(output)
|
||||
)
|
||||
}
|
||||
|
||||
function OperatorTerminalInner() {
|
||||
const searchParams = useSearchParams()
|
||||
const sandboxId = searchParams.get('sandboxId')
|
||||
const launchMode = searchParams.get('launch')
|
||||
const requestedDashboardSessionId = searchParams.get('dashboardSessionId')
|
||||
const [dashboardSessionId, setDashboardSessionId] = useState(
|
||||
() => requestedDashboardSessionId?.trim() || HYDRATION_SAFE_DASHBOARD_SESSION_ID
|
||||
@@ -84,12 +114,18 @@ function OperatorTerminalInner() {
|
||||
const liveSessionRequestRef = useRef<Promise<void> | null>(null)
|
||||
const reconnectCounterRef = useRef(0)
|
||||
const resizeObserverRef = useRef<ResizeObserver | null>(null)
|
||||
const hermesLaunchSentRef = useRef(false)
|
||||
const hermesAgentSentRef = useRef(false)
|
||||
const hermesAttachBufferRef = useRef('')
|
||||
|
||||
useEffect(() => {
|
||||
setDashboardSessionId(ensureDashboardSessionId(requestedDashboardSessionId))
|
||||
}, [requestedDashboardSessionId])
|
||||
|
||||
const terminalDescription = sandboxId ? 'Live operator terminal for the selected sandbox, brokered through the dashboard-owned terminal bridge.' : 'Live operator terminal for host mode, brokered through the dashboard-owned terminal bridge.'
|
||||
const shouldLaunchHermes = launchMode === 'hermes' && Boolean(sandboxId)
|
||||
const terminalDescription = shouldLaunchHermes
|
||||
? 'Live operator terminal for Hermes. The dashboard connects to the sandbox and starts the Hermes CLI.'
|
||||
: sandboxId ? 'Live operator terminal for the selected sandbox, brokered through the dashboard-owned terminal bridge.' : 'Live operator terminal for host mode, brokered through the dashboard-owned terminal bridge.'
|
||||
|
||||
const refreshReadiness = useCallback(async () => {
|
||||
if (!sandboxId) {
|
||||
@@ -119,6 +155,9 @@ function OperatorTerminalInner() {
|
||||
if (reset) {
|
||||
reconnectCounterRef.current += 1
|
||||
liveSessionIdRef.current = ''
|
||||
hermesLaunchSentRef.current = false
|
||||
hermesAgentSentRef.current = false
|
||||
hermesAttachBufferRef.current = ''
|
||||
socketRef.current?.close()
|
||||
socketRef.current = null
|
||||
}
|
||||
@@ -162,6 +201,12 @@ function OperatorTerminalInner() {
|
||||
}
|
||||
}, [dashboardSessionId, sandboxId])
|
||||
|
||||
useEffect(() => {
|
||||
hermesLaunchSentRef.current = false
|
||||
hermesAgentSentRef.current = false
|
||||
hermesAttachBufferRef.current = ''
|
||||
}, [launchMode, sandboxId])
|
||||
|
||||
useEffect(() => { refreshReadiness() }, [refreshReadiness])
|
||||
useEffect(() => { ensureLiveSession() }, [ensureLiveSession])
|
||||
|
||||
@@ -247,7 +292,9 @@ function OperatorTerminalInner() {
|
||||
|
||||
socket.addEventListener('open', () => {
|
||||
setTerminalState('connected')
|
||||
setTerminalStatus(`Live terminal connected for ${liveSession.sandboxId}.`)
|
||||
setTerminalStatus(shouldLaunchHermes
|
||||
? `Live terminal connected for ${liveSession.sandboxId}; launching Hermes…`
|
||||
: `Live terminal connected for ${liveSession.sandboxId}.`)
|
||||
try {
|
||||
fitAddonRef.current?.fit()
|
||||
} catch {
|
||||
@@ -255,6 +302,14 @@ function OperatorTerminalInner() {
|
||||
}
|
||||
term.focus()
|
||||
socket.send(JSON.stringify({ type: 'resize', cols: term.cols, rows: term.rows }))
|
||||
if (shouldLaunchHermes && sandboxId && !hermesLaunchSentRef.current) {
|
||||
hermesLaunchSentRef.current = true
|
||||
window.setTimeout(() => {
|
||||
if (socket.readyState === WebSocket.OPEN) {
|
||||
socket.send(JSON.stringify({ type: 'input', data: `\n\n${buildHermesTerminalConnectCommand(sandboxId)}\n` }))
|
||||
}
|
||||
}, 250)
|
||||
}
|
||||
})
|
||||
|
||||
socket.addEventListener('message', (event) => {
|
||||
@@ -265,6 +320,18 @@ function OperatorTerminalInner() {
|
||||
term.write(message.replay)
|
||||
} else if (message.type === 'data' && typeof message.data === 'string') {
|
||||
term.write(message.data)
|
||||
if (shouldLaunchHermes && sandboxId && !hermesAgentSentRef.current) {
|
||||
hermesAttachBufferRef.current = `${hermesAttachBufferRef.current}${message.data}`.slice(-8000)
|
||||
if (isHermesAttachReadyOutput(hermesAttachBufferRef.current, sandboxId)) {
|
||||
hermesAgentSentRef.current = true
|
||||
setTerminalStatus(`Hermes sandbox ${sandboxId} attached; starting Hermes CLI…`)
|
||||
window.setTimeout(() => {
|
||||
if (socket.readyState === WebSocket.OPEN) {
|
||||
socket.send(JSON.stringify({ type: 'input', data: `\n\n${HERMES_AGENT_COMMAND}\n` }))
|
||||
}
|
||||
}, 350)
|
||||
}
|
||||
}
|
||||
} else if (message.type === 'exit') {
|
||||
setTerminalState('error')
|
||||
setTerminalStatus(`Terminal exited with code ${message.exitCode ?? 'unknown'}.`)
|
||||
@@ -291,7 +358,7 @@ function OperatorTerminalInner() {
|
||||
socket.close()
|
||||
if (socketRef.current === socket) socketRef.current = null
|
||||
}
|
||||
}, [liveSession, terminalReady])
|
||||
}, [liveSession, terminalReady, shouldLaunchHermes, sandboxId])
|
||||
|
||||
const readiness = useMemo(() => {
|
||||
if (!sandboxId) return { tone: 'border-[var(--status-pending)] text-[var(--status-pending)]', label: 'HOST MODE', detail: 'No sandbox query was provided. The dashboard terminal stays in host mode and keeps dashboard-session diagnostics for reconnect behavior.' }
|
||||
|
||||
@@ -341,6 +341,7 @@ export default function Dashboard() {
|
||||
onSandboxSelect={handleSandboxSelect}
|
||||
isDestroyMode={isDestroyMode}
|
||||
onInventoryRefresh={refresh}
|
||||
dashboardSessionId={dashboardSession.dashboardSessionId}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
@@ -429,6 +430,7 @@ export default function Dashboard() {
|
||||
onSandboxSelect={handleSandboxSelect}
|
||||
isDestroyMode={isDestroyMode}
|
||||
onInventoryRefresh={refresh}
|
||||
dashboardSessionId={dashboardSession.dashboardSessionId}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user