Stabilize dashboard runtime proxy
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"use client"
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useState, useEffect, useCallback } from 'react'
|
||||
import CompactGauge from './CompactGauge'
|
||||
|
||||
interface TelemetryData {
|
||||
@@ -9,6 +9,7 @@ interface TelemetryData {
|
||||
gpuMemoryUsed?: number
|
||||
gpuMemoryTotal?: number
|
||||
gpuTemperature?: number
|
||||
timestamp?: string
|
||||
}
|
||||
|
||||
interface Sandbox {
|
||||
@@ -30,25 +31,6 @@ export default function CompactTelemetryDisplay() {
|
||||
fetchSandboxes()
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedSandbox) {
|
||||
fetchTelemetry()
|
||||
} else {
|
||||
fetchCombinedTelemetry()
|
||||
}
|
||||
}, [selectedSandbox])
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
if (selectedSandbox) {
|
||||
fetchTelemetry()
|
||||
} else {
|
||||
fetchCombinedTelemetry()
|
||||
}
|
||||
}, 5000)
|
||||
return () => clearInterval(interval)
|
||||
}, [selectedSandbox])
|
||||
|
||||
const fetchSandboxes = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/telemetry/real')
|
||||
@@ -67,7 +49,7 @@ export default function CompactTelemetryDisplay() {
|
||||
}
|
||||
}
|
||||
|
||||
const fetchTelemetry = async () => {
|
||||
const fetchTelemetry = useCallback(async () => {
|
||||
try {
|
||||
const response = await fetch('/api/telemetry/combined')
|
||||
const data = await response.json()
|
||||
@@ -75,10 +57,29 @@ export default function CompactTelemetryDisplay() {
|
||||
} catch (error) {
|
||||
console.error('Error fetching telemetry:', error)
|
||||
}
|
||||
}
|
||||
}, [])
|
||||
|
||||
const fetchCombinedTelemetry = fetchTelemetry
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedSandbox) {
|
||||
fetchTelemetry()
|
||||
} else {
|
||||
fetchCombinedTelemetry()
|
||||
}
|
||||
}, [selectedSandbox, fetchTelemetry, fetchCombinedTelemetry])
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
if (selectedSandbox) {
|
||||
fetchTelemetry()
|
||||
} else {
|
||||
fetchCombinedTelemetry()
|
||||
}
|
||||
}, 5000)
|
||||
return () => clearInterval(interval)
|
||||
}, [selectedSandbox, fetchTelemetry, fetchCombinedTelemetry])
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-40">
|
||||
|
||||
@@ -8,97 +8,44 @@ type EndpointTls = "" | "terminate" | "passthrough"
|
||||
type EndpointEnforcement = "" | "enforce" | "audit"
|
||||
type EndpointAccess = "" | "read-only" | "read-write" | "full"
|
||||
|
||||
interface NetworkRule {
|
||||
method: string
|
||||
path: string
|
||||
}
|
||||
|
||||
interface NetworkEndpoint {
|
||||
host: string
|
||||
port: string
|
||||
protocol: EndpointProtocol
|
||||
tls: EndpointTls
|
||||
enforcement: EndpointEnforcement
|
||||
access: EndpointAccess
|
||||
rules: NetworkRule[]
|
||||
}
|
||||
|
||||
interface NetworkBinary {
|
||||
path: string
|
||||
}
|
||||
|
||||
interface NetworkPolicyBlock {
|
||||
key: string
|
||||
name: string
|
||||
endpoints: NetworkEndpoint[]
|
||||
binaries: NetworkBinary[]
|
||||
}
|
||||
|
||||
interface NetworkRule { method: string; path: string }
|
||||
interface NetworkEndpoint { host: string; port: string; protocol: EndpointProtocol; tls: EndpointTls; enforcement: EndpointEnforcement; access: EndpointAccess; rules: NetworkRule[] }
|
||||
interface NetworkBinary { path: string }
|
||||
interface NetworkPolicyBlock { key: string; name: string; endpoints: NetworkEndpoint[]; binaries: NetworkBinary[] }
|
||||
type OpenShellPolicy = OpenShellPolicyShape
|
||||
|
||||
type BlueprintOption = {
|
||||
id: string
|
||||
label: string
|
||||
description: string
|
||||
type: "blueprint" | "custom"
|
||||
source: string
|
||||
supportsTailscale?: boolean
|
||||
}
|
||||
|
||||
interface ConfigurationPanelProps {
|
||||
sandboxId: string
|
||||
mode?: 'existing' | 'create'
|
||||
onCreateSuccess?: (sandboxId: string) => void | Promise<void>
|
||||
onInventoryRefresh?: () => Promise<unknown>
|
||||
}
|
||||
|
||||
function FieldHelp({ text }: { text: string }) {
|
||||
return (
|
||||
<span className="ml-2 inline-flex align-middle group relative">
|
||||
<span className="w-4 h-4 rounded-full border border-[var(--foreground-dim)] text-[10px] text-[var(--foreground-dim)] flex items-center justify-center cursor-help">?</span>
|
||||
<span className="pointer-events-none absolute left-0 top-6 z-50 hidden w-80 rounded-sm border border-[var(--border-subtle)] bg-[var(--background-panel)] p-2 text-[11px] text-[var(--foreground)] shadow-lg group-hover:block">
|
||||
{text}
|
||||
</span>
|
||||
</span>
|
||||
)
|
||||
return <span className="ml-2 inline-flex align-middle group relative"><span className="w-4 h-4 rounded-full border border-[var(--foreground-dim)] text-[10px] text-[var(--foreground-dim)] flex items-center justify-center cursor-help">?</span><span className="pointer-events-none absolute left-0 top-6 z-50 hidden w-80 rounded-sm border border-[var(--border-subtle)] bg-[var(--background-panel)] p-2 text-[11px] text-[var(--foreground)] shadow-lg group-hover:block">{text}</span></span>
|
||||
}
|
||||
|
||||
function Badge({ children, tone }: { children: React.ReactNode; tone: "dynamic" | "static" | "danger" }) {
|
||||
const cls = tone === "dynamic"
|
||||
? "bg-[rgba(118,185,0,0.12)] text-[var(--nvidia-green)] border-[rgba(118,185,0,0.35)]"
|
||||
: tone === "danger"
|
||||
? "bg-[rgba(220,38,38,0.12)] text-red-400 border-[rgba(220,38,38,0.35)]"
|
||||
: "bg-[rgba(245,158,11,0.10)] text-amber-400 border-[rgba(245,158,11,0.35)]"
|
||||
const cls = tone === "dynamic" ? "bg-[rgba(118,185,0,0.12)] text-[var(--nvidia-green)] border-[rgba(118,185,0,0.35)]" : tone === "danger" ? "bg-[rgba(220,38,38,0.12)] text-red-400 border-[rgba(220,38,38,0.35)]" : "bg-[rgba(245,158,11,0.10)] text-amber-400 border-[rgba(245,158,11,0.35)]"
|
||||
return <span className={`text-[10px] uppercase tracking-wider border px-2 py-1 rounded-sm ${cls}`}>{children}</span>
|
||||
}
|
||||
|
||||
function TextListEditor({ label, tooltipText, value, onChange, placeholder }: {
|
||||
label: string
|
||||
tooltipText: string
|
||||
value: string[]
|
||||
onChange: (v: string[]) => void
|
||||
placeholder: string
|
||||
}) {
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<label className="text-xs uppercase tracking-wider text-[var(--foreground-dim)]">
|
||||
{label}
|
||||
<FieldHelp text={tooltipText} />
|
||||
</label>
|
||||
<textarea
|
||||
value={value.join("\n")}
|
||||
onChange={(e) => onChange(e.target.value.split("\n").map(s => s.trim()).filter(Boolean))}
|
||||
placeholder={placeholder}
|
||||
rows={4}
|
||||
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)] focus:outline-none focus:border-[var(--nvidia-green)]"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
function TextListEditor({ label, tooltipText, value, onChange, placeholder }: { label: string; tooltipText: string; value: string[]; onChange: (v: string[]) => void; placeholder: string }) {
|
||||
return <div className="space-y-2"><label className="text-xs uppercase tracking-wider text-[var(--foreground-dim)]">{label}<FieldHelp text={tooltipText} /></label><textarea value={value.join("\n")} onChange={(e) => onChange(e.target.value.split("\n").map(s => s.trim()).filter(Boolean))} placeholder={placeholder} rows={4} 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)] focus:outline-none focus:border-[var(--nvidia-green)]" /></div>
|
||||
}
|
||||
|
||||
const defaultPolicy: OpenShellPolicy = {
|
||||
version: 1,
|
||||
filesystem_policy: {
|
||||
include_workdir: true,
|
||||
read_only: ["/usr", "/lib", "/etc", "/proc", "/dev/urandom"],
|
||||
read_write: ["/sandbox", "/tmp", "/dev/null"],
|
||||
},
|
||||
landlock: {
|
||||
compatibility: "best_effort",
|
||||
},
|
||||
process: {
|
||||
run_as_user: "sandbox",
|
||||
run_as_group: "sandbox",
|
||||
},
|
||||
filesystem_policy: { include_workdir: true, read_only: ["/usr", "/lib", "/etc", "/proc", "/dev/urandom"], read_write: ["/sandbox", "/tmp", "/dev/null"] },
|
||||
landlock: { compatibility: "best_effort" },
|
||||
process: { run_as_user: "sandbox", run_as_group: "sandbox" },
|
||||
network_policies: {},
|
||||
}
|
||||
|
||||
@@ -111,67 +58,39 @@ function normalizeFromApi(data: any): OpenShellPolicy {
|
||||
read_only: Array.isArray(current.filesystem_policy?.read_only) ? current.filesystem_policy.read_only : defaultPolicy.filesystem_policy.read_only,
|
||||
read_write: Array.isArray(current.filesystem_policy?.read_write) ? current.filesystem_policy.read_write : defaultPolicy.filesystem_policy.read_write,
|
||||
},
|
||||
landlock: {
|
||||
compatibility: current.landlock?.compatibility === "hard_requirement" ? "hard_requirement" : "best_effort",
|
||||
},
|
||||
process: {
|
||||
run_as_user: String(current.process?.run_as_user ?? "sandbox"),
|
||||
run_as_group: String(current.process?.run_as_group ?? "sandbox"),
|
||||
},
|
||||
landlock: { compatibility: current.landlock?.compatibility === "hard_requirement" ? "hard_requirement" : "best_effort" },
|
||||
process: { run_as_user: String(current.process?.run_as_user ?? "sandbox"), run_as_group: String(current.process?.run_as_group ?? "sandbox") },
|
||||
network_policies: current.network_policies && typeof current.network_policies === "object" ? current.network_policies : {},
|
||||
}
|
||||
}
|
||||
|
||||
function policyBlocksFromPolicy(policy: OpenShellPolicy): NetworkPolicyBlock[] {
|
||||
return Object.entries(policy.network_policies).map(([key, value]) => ({
|
||||
key,
|
||||
name: value.name || key,
|
||||
endpoints: (value.endpoints || []).map((ep) => ({
|
||||
host: ep.host || "",
|
||||
port: String(ep.port ?? "443"),
|
||||
protocol: ep.protocol === "rest" ? "rest" : "",
|
||||
tls: ep.tls === "terminate" || ep.tls === "passthrough" ? ep.tls : "",
|
||||
enforcement: ep.enforcement === "enforce" || ep.enforcement === "audit" ? ep.enforcement : "",
|
||||
access: ep.access === "read-only" || ep.access === "read-write" || ep.access === "full" ? ep.access : "",
|
||||
rules: Array.isArray(ep.rules) ? ep.rules.map((r) => ({ method: r.allow?.method || "GET", path: r.allow?.path || "/**" })) : [],
|
||||
})),
|
||||
binaries: (value.binaries || []).map((b) => ({ path: b.path || "" })),
|
||||
}))
|
||||
return Object.entries(policy.network_policies).map(([key, value]) => ({ key, name: value.name || key, endpoints: (value.endpoints || []).map((ep) => ({ host: ep.host || "", port: String(ep.port ?? "443"), protocol: ep.protocol === "rest" ? "rest" : "", tls: ep.tls === "terminate" || ep.tls === "passthrough" ? ep.tls : "", enforcement: ep.enforcement === "enforce" || ep.enforcement === "audit" ? ep.enforcement : "", access: ep.access === "read-only" || ep.access === "read-write" || ep.access === "full" ? ep.access : "", rules: Array.isArray(ep.rules) ? ep.rules.map((r) => ({ method: r.allow?.method || "GET", path: r.allow?.path || "/**" })) : [] })), binaries: (value.binaries || []).map((b) => ({ path: b.path || "" })) }))
|
||||
}
|
||||
|
||||
function blocksToPolicy(blocks: NetworkPolicyBlock[]): OpenShellPolicy["network_policies"] {
|
||||
const out: OpenShellPolicy["network_policies"] = {}
|
||||
for (const block of blocks) {
|
||||
const key = block.key.trim()
|
||||
if (!key) continue
|
||||
out[key] = {
|
||||
name: block.name.trim() || key,
|
||||
endpoints: block.endpoints.filter((ep) => ep.host.trim() && ep.port.trim()).map((ep) => ({
|
||||
host: ep.host.trim(),
|
||||
port: Number(ep.port),
|
||||
...(ep.protocol ? { protocol: ep.protocol } : {}),
|
||||
...(ep.tls ? { tls: ep.tls } : {}),
|
||||
...(ep.enforcement ? { enforcement: ep.enforcement } : {}),
|
||||
...(ep.access ? { access: ep.access } : {}),
|
||||
...(!ep.access && ep.rules.length ? { rules: ep.rules.filter((r) => r.method.trim() && r.path.trim()).map((r) => ({ allow: { method: r.method.trim(), path: r.path.trim() } })) } : {}),
|
||||
})),
|
||||
binaries: block.binaries.filter((b) => b.path.trim()).map((b) => ({ path: b.path.trim() })),
|
||||
}
|
||||
const key = block.key.trim(); if (!key) continue
|
||||
out[key] = { name: block.name.trim() || key, endpoints: block.endpoints.filter((ep) => ep.host.trim() && ep.port.trim()).map((ep) => ({ host: ep.host.trim(), port: Number(ep.port), ...(ep.protocol ? { protocol: ep.protocol } : {}), ...(ep.tls ? { tls: ep.tls } : {}), ...(ep.enforcement ? { enforcement: ep.enforcement } : {}), ...(ep.access ? { access: ep.access } : {}), ...(!ep.access && ep.rules.length ? { rules: ep.rules.filter((r) => r.method.trim() && r.path.trim()).map((r) => ({ allow: { method: r.method.trim(), path: r.path.trim() } })) } : {}) })), binaries: block.binaries.filter((b) => b.path.trim()).map((b) => ({ path: b.path.trim() })) }
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
export default function ConfigurationPanel({ sandboxId, mode = 'existing' }: ConfigurationPanelProps) {
|
||||
export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCreateSuccess, onInventoryRefresh }: ConfigurationPanelProps) {
|
||||
const [policy, setPolicy] = useState<OpenShellPolicy>(defaultPolicy)
|
||||
const [blocks, setBlocks] = useState<NetworkPolicyBlock[]>([])
|
||||
const [loading, setLoading] = useState(mode === 'existing')
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [message, setMessage] = useState("")
|
||||
const [selectedPreset, setSelectedPreset] = useState<SecurityPresetId | ''>('')
|
||||
const [blueprints, setBlueprints] = useState<BlueprintOption[]>([])
|
||||
const [selectedBlueprint, setSelectedBlueprint] = useState<string>('nemoclaw-blueprint')
|
||||
const [sandboxName, setSandboxName] = useState<string>('')
|
||||
const [enableTailscale, setEnableTailscale] = useState<boolean>(false)
|
||||
|
||||
useEffect(() => {
|
||||
if (mode === 'create') {
|
||||
setLoading(false)
|
||||
fetch('/api/sandbox/create', { cache: 'no-store' }).then((res) => res.json()).then((data) => { if (Array.isArray(data?.blueprints)) setBlueprints(data.blueprints) }).catch(() => {})
|
||||
return
|
||||
}
|
||||
let active = true
|
||||
@@ -197,184 +116,60 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing' }: Con
|
||||
|
||||
const assembledPolicy = useMemo(() => ({ ...policy, network_policies: blocksToPolicy(blocks) }), [policy, blocks])
|
||||
const activePreset = selectedPreset ? getSecurityPreset(selectedPreset) : null
|
||||
const showDangerWarning = activePreset?.id === 'spicy' || activePreset?.id === 'ultra-lobster'
|
||||
const activeBlueprint = blueprints.find((bp) => bp.id === selectedBlueprint)
|
||||
|
||||
function applyPreset(presetId: SecurityPresetId) {
|
||||
const preset = getSecurityPreset(presetId)
|
||||
if (!preset) return
|
||||
setSelectedPreset(presetId)
|
||||
setPolicy(preset.policy)
|
||||
setBlocks(policyBlocksFromPolicy(preset.policy))
|
||||
setMessage(`${preset.label} applied. Review before saving.${preset.id === 'spicy' || preset.id === 'ultra-lobster' ? ' Warning: this preset is intentionally permissive.' : ''}`)
|
||||
const preset = getSecurityPreset(presetId); if (!preset) return
|
||||
setSelectedPreset(presetId); setPolicy(preset.policy); setBlocks(policyBlocksFromPolicy(preset.policy)); setMessage(`${preset.label} applied. Review before saving.`)
|
||||
}
|
||||
|
||||
async function savePolicy() {
|
||||
try {
|
||||
setSaving(true)
|
||||
setMessage("")
|
||||
const res = await fetch(`/api/sandbox/${encodeURIComponent(sandboxId)}/config`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ policy: assembledPolicy, preset: selectedPreset || null, mode }),
|
||||
})
|
||||
const data = await res.json()
|
||||
if (!res.ok) throw new Error(data.error || "Failed to save policy")
|
||||
setMessage(mode === 'create'
|
||||
? 'Preset and policy prepared for new sandbox creation. Static sections will apply at create time.'
|
||||
: 'Policy saved. Dynamic network policy can apply live; static sections require sandbox recreation.')
|
||||
setSaving(true); setMessage("")
|
||||
if (mode === 'create') {
|
||||
if (!sandboxName.trim()) throw new Error('sandbox name is required')
|
||||
const res = await fetch('/api/sandbox/create', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ blueprint: selectedBlueprint, sandboxName: sandboxName.trim(), enableTailscale, 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.gatewayReusePolicy, data.stdout, data.stderr].filter(Boolean).join('\n\n'))
|
||||
const createdSandboxId = data.verification?.details?.id || data.verification?.details?.name || data.sandboxName
|
||||
if (onInventoryRefresh) {
|
||||
await onInventoryRefresh()
|
||||
}
|
||||
setMessage([
|
||||
`Sandbox '${data.sandboxName}' created via ${data.mode}.${data.enableTailscale ? ' Tailscale-enabled path requested.' : ' Tailscale disabled.'}`,
|
||||
data.verification?.summary,
|
||||
data.gatewayReusePolicy,
|
||||
'Inventory refresh requested immediately.',
|
||||
].filter(Boolean).join('\n\n'))
|
||||
if (createdSandboxId && onCreateSuccess) {
|
||||
await onCreateSuccess(createdSandboxId)
|
||||
}
|
||||
return
|
||||
}
|
||||
const res = await fetch(`/api/sandbox/${encodeURIComponent(sandboxId)}/config`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ policy: assembledPolicy, preset: selectedPreset || null, mode }) })
|
||||
const data = await res.json(); if (!res.ok) throw new Error(data.error || "Failed to save policy")
|
||||
setMessage('Policy saved. Dynamic network policy can apply live; static sections require sandbox recreation.')
|
||||
} catch (err) {
|
||||
setMessage(err instanceof Error ? err.message : "Failed to save policy")
|
||||
} finally {
|
||||
setSaving(false)
|
||||
}
|
||||
} finally { setSaving(false) }
|
||||
}
|
||||
|
||||
function updateBlock(idx: number, next: NetworkPolicyBlock) {
|
||||
setBlocks((prev) => prev.map((b, i) => (i === idx ? next : b)))
|
||||
}
|
||||
|
||||
function addBlock() {
|
||||
setBlocks((prev) => [...prev, {
|
||||
key: `policy_${prev.length + 1}`,
|
||||
name: `policy-${prev.length + 1}`,
|
||||
endpoints: [{ host: "", port: "443", protocol: "", tls: "", enforcement: "", access: "read-only", rules: [] }],
|
||||
binaries: [{ path: "" }],
|
||||
}])
|
||||
}
|
||||
function updateBlock(idx: number, next: NetworkPolicyBlock) { setBlocks((prev) => prev.map((b, i) => (i === idx ? next : b))) }
|
||||
function addBlock() { setBlocks((prev) => [...prev, { key: `policy_${prev.length + 1}`, name: `policy-${prev.length + 1}`, endpoints: [{ host: "", port: "443", protocol: "", tls: "", enforcement: "", access: "read-only", rules: [] }], binaries: [{ path: "" }] }]) }
|
||||
|
||||
return (
|
||||
<div className="panel p-6 mt-6 border-t-2 border-[var(--nvidia-green)]">
|
||||
<div className="flex items-center justify-between mb-6 pb-4 border-b border-[var(--border-subtle)]">
|
||||
<h4 className="text-sm font-semibold text-[var(--foreground)] uppercase tracking-wider">{sandboxId} — {mode === 'create' ? 'NEW SANDBOX PRESET + POLICY' : 'OPENSHELL POLICY'}</h4>
|
||||
<div className="flex gap-2">
|
||||
<Badge tone="static">Static / Recreate Required</Badge>
|
||||
<Badge tone="dynamic">Dynamic / Apply Live</Badge>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{loading ? <div className="text-sm text-[var(--foreground-dim)]">Loading policy…</div> : (
|
||||
<div className="space-y-8">
|
||||
<section className="space-y-4">
|
||||
<div className="flex items-center justify-between gap-4 flex-wrap">
|
||||
<div>
|
||||
<h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Security Presets</h5>
|
||||
<p className="text-xs text-[var(--foreground-dim)] mt-1">Use a canned profile for new sandboxes or switch an existing sandbox policy baseline on the fly.</p>
|
||||
</div>
|
||||
<div className="min-w-[260px]">
|
||||
<select
|
||||
value={selectedPreset}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value as SecurityPresetId | ''
|
||||
setSelectedPreset(value)
|
||||
if (value) applyPreset(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)]"
|
||||
>
|
||||
<option value="">Select preset…</option>
|
||||
{SECURITY_PRESETS.map((preset) => (
|
||||
<option key={preset.id} value={preset.id}>{preset.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{activePreset && (
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4 space-y-3">
|
||||
<div className="flex items-center gap-3 flex-wrap">
|
||||
<span className="text-sm font-semibold text-[var(--foreground)] uppercase tracking-wider">{activePreset.label}</span>
|
||||
<Badge tone={showDangerWarning ? 'danger' : 'dynamic'}>{activePreset.danger.replace('-', ' ')}</Badge>
|
||||
{showDangerWarning && <Badge tone="danger">Dangerous / Permissive</Badge>}
|
||||
</div>
|
||||
<p className="text-sm text-[var(--foreground-dim)]">{activePreset.summary}</p>
|
||||
{(activePreset.id === 'spicy' || activePreset.id === 'ultra-lobster') && (
|
||||
<div className="rounded-sm border border-red-500/40 bg-red-500/10 p-3 text-sm text-red-300">
|
||||
Warning: {activePreset.label} may be dangerous due to its permissive security stance. Use only on trusted lab workloads.
|
||||
</div>
|
||||
)}
|
||||
<div>
|
||||
<p className="text-xs uppercase tracking-wider text-[var(--foreground-dim)] mb-2">Preset exec allowlist</p>
|
||||
<pre className="overflow-auto rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-3 text-[11px] text-[var(--foreground)]">{activePreset.execAllowlist.paths.join('\n')}</pre>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section className="space-y-4">
|
||||
<div className="flex items-center gap-3"><h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Filesystem Policy</h5><Badge tone="static">Static</Badge></div>
|
||||
<label className="flex items-center gap-3 text-sm text-[var(--foreground)] font-mono">
|
||||
<input type="checkbox" checked={policy.filesystem_policy.include_workdir} onChange={(e) => setPolicy({ ...policy, filesystem_policy: { ...policy.filesystem_policy, include_workdir: e.target.checked } })} />
|
||||
Include workdir
|
||||
<FieldHelp text="Automatically adds the agent working directory to read_write. Static: changing this requires recreating the sandbox." />
|
||||
</label>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<TextListEditor label="Read-only paths" tooltipText="Absolute paths the sandbox can read but not modify. Paths not listed are inaccessible." value={policy.filesystem_policy.read_only} onChange={(v) => setPolicy({ ...policy, filesystem_policy: { ...policy.filesystem_policy, read_only: v } })} placeholder="/usr\n/lib\n/etc" />
|
||||
<TextListEditor label="Read-write paths" tooltipText="Absolute paths the sandbox can read and write. Keep this scoped; broad paths are rejected." value={policy.filesystem_policy.read_write} onChange={(v) => setPolicy({ ...policy, filesystem_policy: { ...policy.filesystem_policy, read_write: v } })} placeholder="/sandbox\n/tmp" />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="space-y-4">
|
||||
<div className="flex items-center gap-3"><h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Landlock + Process</h5><Badge tone="static">Static</Badge></div>
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<div>
|
||||
<label className="text-xs uppercase tracking-wider text-[var(--foreground-dim)]">Landlock compatibility<FieldHelp text="best_effort uses the highest kernel ABI available. hard_requirement fails if the required ABI is unavailable." /></label>
|
||||
<select value={policy.landlock.compatibility} onChange={(e) => setPolicy({ ...policy, landlock: { compatibility: e.target.value as LandlockCompatibility } })} className="mt-2 w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] px-3 py-2 text-xs font-mono"><option value="best_effort">best_effort</option><option value="hard_requirement">hard_requirement</option></select>
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-xs uppercase tracking-wider text-[var(--foreground-dim)]">Run as user<FieldHelp text="OS-level user for the sandbox process. Upstream policy validation expects sandbox; root is rejected." /></label>
|
||||
<input value={policy.process.run_as_user} onChange={(e) => setPolicy({ ...policy, process: { ...policy.process, run_as_user: e.target.value } })} className="mt-2 w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] px-3 py-2 text-xs font-mono" />
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-xs uppercase tracking-wider text-[var(--foreground-dim)]">Run as group<FieldHelp text="OS-level group for the sandbox process. Upstream policy validation expects sandbox; root is rejected." /></label>
|
||||
<input value={policy.process.run_as_group} onChange={(e) => setPolicy({ ...policy, process: { ...policy.process, run_as_group: e.target.value } })} className="mt-2 w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] px-3 py-2 text-xs font-mono" />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-3"><h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Network Policies</h5><Badge tone="dynamic">Dynamic</Badge></div>
|
||||
<button onClick={addBlock} className="px-3 py-2 rounded-sm bg-[var(--background-tertiary)] text-xs font-mono uppercase tracking-wider hover:bg-[var(--background-panel)]">Add policy block</button>
|
||||
</div>
|
||||
<p className="text-xs text-[var(--foreground-dim)]">Named endpoint + binary allowlists. These are hot-reloadable on running sandboxes via policy updates.</p>
|
||||
<div className="space-y-6">
|
||||
{blocks.length === 0 && <div className="text-sm text-[var(--foreground-dim)]">No network policies defined.</div>}
|
||||
{blocks.map((block, idx) => (
|
||||
<div key={idx} className="border border-[var(--border-subtle)] rounded-sm p-4 space-y-4 bg-[var(--background-tertiary)]">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div><label className="text-xs uppercase tracking-wider text-[var(--foreground-dim)]">Policy key<FieldHelp text="Logical identifier in network_policies map." /></label><input value={block.key} onChange={(e) => updateBlock(idx, { ...block, key: e.target.value })} className="mt-2 w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] px-3 py-2 text-xs font-mono" /></div>
|
||||
<div><label className="text-xs uppercase tracking-wider text-[var(--foreground-dim)]">Display name<FieldHelp text="Optional display name used in logs; defaults to the key." /></label><input value={block.name} onChange={(e) => updateBlock(idx, { ...block, name: e.target.value })} className="mt-2 w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] px-3 py-2 text-xs font-mono" /></div>
|
||||
</div>
|
||||
<div className="space-y-4">
|
||||
<div className="text-xs uppercase tracking-wider text-[var(--foreground)]">Endpoints</div>
|
||||
{block.endpoints.map((ep, epIdx) => (
|
||||
<div key={epIdx} className="grid grid-cols-1 md:grid-cols-6 gap-3 border border-[var(--border-subtle)] p-3 rounded-sm">
|
||||
<input placeholder="host" value={ep.host} onChange={(e) => { const next = [...block.endpoints]; next[epIdx] = { ...ep, host: e.target.value }; updateBlock(idx, { ...block, endpoints: next }) }} className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] px-2 py-2 text-xs font-mono" />
|
||||
<input placeholder="port" value={ep.port} onChange={(e) => { const next = [...block.endpoints]; next[epIdx] = { ...ep, port: e.target.value }; updateBlock(idx, { ...block, endpoints: next }) }} className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] px-2 py-2 text-xs font-mono" />
|
||||
<select value={ep.protocol} onChange={(e) => { const next = [...block.endpoints]; next[epIdx] = { ...ep, protocol: e.target.value as EndpointProtocol }; updateBlock(idx, { ...block, endpoints: next }) }} className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] px-2 py-2 text-xs font-mono"><option value="">protocol</option><option value="rest">rest</option></select>
|
||||
<select value={ep.tls} onChange={(e) => { const next = [...block.endpoints]; next[epIdx] = { ...ep, tls: e.target.value as EndpointTls }; updateBlock(idx, { ...block, endpoints: next }) }} className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] px-2 py-2 text-xs font-mono"><option value="">tls</option><option value="terminate">terminate</option><option value="passthrough">passthrough</option></select>
|
||||
<select value={ep.enforcement} onChange={(e) => { const next = [...block.endpoints]; next[epIdx] = { ...ep, enforcement: e.target.value as EndpointEnforcement }; updateBlock(idx, { ...block, endpoints: next }) }} className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] px-2 py-2 text-xs font-mono"><option value="">enforcement</option><option value="enforce">enforce</option><option value="audit">audit</option></select>
|
||||
<select value={ep.access} onChange={(e) => { const next = [...block.endpoints]; next[epIdx] = { ...ep, access: e.target.value as EndpointAccess }; updateBlock(idx, { ...block, endpoints: next }) }} className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] px-2 py-2 text-xs font-mono"><option value="">rules mode</option><option value="read-only">read-only</option><option value="read-write">read-write</option><option value="full">full</option></select>
|
||||
</div>
|
||||
))}
|
||||
<button onClick={() => updateBlock(idx, { ...block, endpoints: [...block.endpoints, { host: "", port: "443", protocol: "", tls: "", enforcement: "", access: "", rules: [{ method: "GET", path: "/**" }] }] })} className="px-3 py-2 rounded-sm bg-[var(--background)] text-xs font-mono uppercase tracking-wider">Add endpoint</button>
|
||||
</div>
|
||||
<div className="space-y-3">
|
||||
<div className="text-xs uppercase tracking-wider text-[var(--foreground)]">Binaries</div>
|
||||
{block.binaries.map((bin, binIdx) => (<input key={binIdx} placeholder="/usr/bin/curl" value={bin.path} onChange={(e) => { const next = [...block.binaries]; next[binIdx] = { path: e.target.value }; updateBlock(idx, { ...block, binaries: next }) }} className="w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] px-3 py-2 text-xs font-mono" />))}
|
||||
<button onClick={() => updateBlock(idx, { ...block, binaries: [...block.binaries, { path: "" }] })} className="px-3 py-2 rounded-sm bg-[var(--background)] text-xs font-mono uppercase tracking-wider">Add binary</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="space-y-3">
|
||||
<div className="flex items-center justify-between"><h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Policy JSON Preview</h5><button onClick={savePolicy} disabled={saving} className="px-4 py-2 rounded-sm bg-[var(--nvidia-green)] text-white text-xs font-mono uppercase tracking-wider disabled:opacity-50">{saving ? "Saving…" : mode === 'create' ? 'Use For New Sandbox' : 'Save Policy'}</button></div>
|
||||
<pre className="overflow-auto rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4 text-[11px] leading-5 text-[var(--foreground)]">{JSON.stringify(assembledPolicy, null, 2)}</pre>
|
||||
{message && <div className="text-sm text-[var(--foreground-dim)]">{message}</div>}
|
||||
</section>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex items-center justify-between mb-6 pb-4 border-b border-[var(--border-subtle)]"><h4 className="text-sm font-semibold text-[var(--foreground)] uppercase tracking-wider">{mode === 'create' ? 'CREATE SANDBOX WORKFLOW' : `${sandboxId} — OPENSHELL POLICY`}</h4><div className="flex gap-2"><Badge tone="static">Static / Recreate Required</Badge><Badge tone="dynamic">Dynamic / Apply Live</Badge></div></div>
|
||||
{loading ? <div className="text-sm text-[var(--foreground-dim)]">Loading policy…</div> : <div className="space-y-8">
|
||||
{mode === 'create' && <section className="space-y-4 rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4"><div><h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Create Sandbox</h5><p className="text-xs text-[var(--foreground-dim)] mt-1">Choose a blueprint-backed workflow or create a custom sandbox, then provide a sandbox name.</p></div><div className="rounded-sm border border-[rgba(118,185,0,0.25)] bg-[rgba(118,185,0,0.08)] p-3 text-xs text-[var(--foreground-dim)] whitespace-pre-wrap">Gateway reuse policy:
|
||||
- reuse the existing OpenShell gateway when `openshell status` reports `Connected`
|
||||
- only start a fresh gateway when no healthy gateway is already connected
|
||||
- force non-interactive PATH to include $HOME/.local/bin so openshell resolves during setup</div><div className="grid grid-cols-1 md:grid-cols-2 gap-4">{blueprints.map((bp) => <button key={bp.id} type="button" onClick={() => setSelectedBlueprint(bp.id)} className={`rounded-sm border p-4 text-left ${selectedBlueprint === bp.id ? 'border-[var(--nvidia-green)] bg-[rgba(118,185,0,0.08)]' : 'border-[var(--border-subtle)] bg-[var(--background)]'}`}><div className="flex items-center justify-between gap-3"><span className="text-sm font-semibold text-[var(--foreground)] uppercase tracking-wider">{bp.label}</span><Badge tone={bp.type === 'custom' ? 'static' : 'dynamic'}>{bp.type}</Badge></div><p className="text-xs text-[var(--foreground-dim)] mt-2">{bp.description}</p><p className="text-[10px] font-mono text-[var(--foreground-dim)] mt-3">{bp.source}</p></button>)}</div><div><label className="text-xs uppercase tracking-wider text-[var(--foreground-dim)]">Sandbox Name<FieldHelp text="Operator-facing sandbox name used by OpenShell create/connect flows. Lowercase letters, numbers, and hyphens only." /></label><input value={sandboxName} onChange={(e) => setSandboxName(e.target.value)} placeholder={selectedBlueprint === 'nemoclaw-blueprint' ? 'my-assistant' : '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>{activeBlueprint?.supportsTailscale && <label className="flex items-center gap-3 text-sm text-[var(--foreground)] font-mono"><input type="checkbox" checked={enableTailscale} onChange={(e) => setEnableTailscale(e.target.checked)} /> Enable Tailscale <FieldHelp text="Optional. Only enable this when you want the Tailscale/NVIDIA-backed path. This is the only case where NVIDIA_API_KEY should be required." /></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>}</section>}
|
||||
<section className="space-y-4"><div className="flex items-center justify-between gap-4 flex-wrap"><div><h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Security Presets</h5><p className="text-xs text-[var(--foreground-dim)] mt-1">Use a canned profile for new sandboxes or switch an existing sandbox policy baseline on the fly.</p></div><div className="min-w-[260px]"><select value={selectedPreset} onChange={(e) => { const value = e.target.value as SecurityPresetId | ''; setSelectedPreset(value); if (value) applyPreset(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)]"><option value="">Select preset…</option>{SECURITY_PRESETS.map((preset) => <option key={preset.id} value={preset.id}>{preset.label}</option>)}</select></div></div>{activePreset && <div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4 space-y-3"><div className="flex items-center gap-3 flex-wrap"><span className="text-sm font-semibold text-[var(--foreground)] uppercase tracking-wider">{activePreset.label}</span></div><p className="text-sm text-[var(--foreground-dim)]">{activePreset.summary}</p></div>}</section>
|
||||
<section className="space-y-4"><div className="flex items-center gap-3"><h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Filesystem Policy</h5><Badge tone="static">Static</Badge></div><label className="flex items-center gap-3 text-sm text-[var(--foreground)] font-mono"><input type="checkbox" checked={policy.filesystem_policy.include_workdir} onChange={(e) => setPolicy({ ...policy, filesystem_policy: { ...policy.filesystem_policy, include_workdir: e.target.checked } })} />Include workdir<FieldHelp text="Automatically adds the agent working directory to read_write. Static: changing this requires recreating the sandbox." /></label><div className="grid grid-cols-1 md:grid-cols-2 gap-4"><TextListEditor label="Read-only paths" tooltipText="Absolute paths the sandbox can read but not modify. Paths not listed are inaccessible." value={policy.filesystem_policy.read_only} onChange={(v) => setPolicy({ ...policy, filesystem_policy: { ...policy.filesystem_policy, read_only: v } })} placeholder="/usr\n/lib\n/etc" /><TextListEditor label="Read-write paths" tooltipText="Absolute paths the sandbox can read and write. Keep this scoped; broad paths are rejected." value={policy.filesystem_policy.read_write} onChange={(v) => setPolicy({ ...policy, filesystem_policy: { ...policy.filesystem_policy, read_write: v } })} placeholder="/sandbox\n/tmp" /></div></section>
|
||||
<section className="space-y-4"><div className="flex items-center gap-3"><h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Network Policies</h5><Badge tone="dynamic">Dynamic</Badge></div><button onClick={addBlock} className="px-3 py-2 rounded-sm bg-[var(--background-tertiary)] text-xs font-mono uppercase tracking-wider hover:bg-[var(--background-panel)]">Add policy block</button></section>
|
||||
<section className="space-y-3"><div className="flex items-center justify-between"><h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Policy JSON Preview</h5><button onClick={savePolicy} disabled={saving} className="px-4 py-2 rounded-sm bg-[var(--nvidia-green)] text-white text-xs font-mono uppercase tracking-wider disabled:opacity-50">{saving ? "Working…" : mode === 'create' ? 'Create Sandbox' : 'Save Policy'}</button></div><pre className="overflow-auto rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4 text-[11px] leading-5 text-[var(--foreground)]">{JSON.stringify(assembledPolicy, null, 2)}</pre>{message && <div className="text-sm text-[var(--foreground-dim)] whitespace-pre-wrap">{message}</div>}</section>
|
||||
</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use client"
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useState, useEffect, useCallback } from 'react'
|
||||
import CompactGauge from './CompactGauge'
|
||||
|
||||
interface TelemetryData {
|
||||
@@ -9,6 +9,7 @@ interface TelemetryData {
|
||||
gpuMemoryUsed?: number
|
||||
gpuMemoryTotal?: number
|
||||
gpuTemperature?: number
|
||||
timestamp?: string
|
||||
}
|
||||
|
||||
interface SandboxConfig {
|
||||
@@ -42,15 +43,7 @@ export default function SandboxDetails({
|
||||
{ name: 'debugMode', description: 'Enable debug logging', enabled: false }
|
||||
])
|
||||
|
||||
useEffect(() => {
|
||||
if (sandboxId) {
|
||||
fetchTelemetry()
|
||||
const interval = setInterval(fetchTelemetry, 5000)
|
||||
return () => clearInterval(interval)
|
||||
}
|
||||
}, [sandboxId])
|
||||
|
||||
const fetchTelemetry = async () => {
|
||||
const fetchTelemetry = useCallback(async () => {
|
||||
if (!sandboxId) return
|
||||
setLoading(true)
|
||||
try {
|
||||
@@ -62,7 +55,15 @@ export default function SandboxDetails({
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
}, [sandboxId])
|
||||
|
||||
useEffect(() => {
|
||||
if (sandboxId) {
|
||||
fetchTelemetry()
|
||||
const interval = setInterval(fetchTelemetry, 5000)
|
||||
return () => clearInterval(interval)
|
||||
}
|
||||
}, [sandboxId, fetchTelemetry])
|
||||
|
||||
const toggleConfig = (name: string) => {
|
||||
setConfig(config.map(item =>
|
||||
|
||||
+160
-106
@@ -1,16 +1,8 @@
|
||||
"use client"
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { useEffect, useState } from 'react'
|
||||
import ConfigurationPanel from './ConfigurationPanel'
|
||||
|
||||
interface Sandbox {
|
||||
id: string
|
||||
name: string
|
||||
namespace: string
|
||||
ip: string
|
||||
status: 'running' | 'pending' | 'stopped' | 'unknown'
|
||||
ready: boolean
|
||||
}
|
||||
import type { NemoClawSummary, SandboxInventoryItem } from '../hooks/useSandboxInventory'
|
||||
import { buildOperatorTerminalRoute } from '../lib/dashboardSession'
|
||||
|
||||
interface TelemetryData {
|
||||
cpu: number
|
||||
@@ -23,63 +15,68 @@ interface TelemetryData {
|
||||
}
|
||||
|
||||
interface SandboxListProps {
|
||||
selectedSandbox: string | null
|
||||
sandboxes: SandboxInventoryItem[]
|
||||
nemoclaw: NemoClawSummary | null
|
||||
dashboardSessionId: string
|
||||
selectedSandboxId: string | null
|
||||
selectedSandbox: SandboxInventoryItem | null
|
||||
onSandboxSelect: (id: string | null) => void
|
||||
isDestroyMode: boolean
|
||||
onInventoryRefresh: () => Promise<SandboxInventoryItem[]>
|
||||
}
|
||||
|
||||
function renderDashboardTruthMessage(data: any) {
|
||||
const listenerSummary = data.listenerSummary ? `\nListener: ${data.listenerSummary}` : ''
|
||||
const showUpstreamSummary = !data.reachable || data.degraded || data.truthState !== 'verified'
|
||||
const upstreamSummary = showUpstreamSummary && (data.upstreamStatus || data.upstreamStatusText)
|
||||
? `\nUpstream probe: ${data.upstreamStatus ?? 'no-status'} ${data.upstreamStatusText ?? ''}`.trimEnd()
|
||||
: ''
|
||||
const inventorySummary = typeof data.inventoryCount === 'number'
|
||||
? `Inventory visibility: ${data.inventoryCount} live sandbox${data.inventoryCount === 1 ? '' : 'es'}.`
|
||||
: 'Inventory visibility: unknown.'
|
||||
const mappingSummary = data.sandboxId
|
||||
? (data.authority?.usedMappedSandboxInstance
|
||||
? `Sandbox ${data.sandboxId} resolved to OpenClaw instance ${data.instanceId} via bridge mapping (fallback-active).`
|
||||
: `Sandbox ${data.sandboxId} resolved to OpenClaw instance ${data.instanceId}.`)
|
||||
: `OpenClaw instance: ${data.instanceId}.`
|
||||
const reachabilitySummary = data.reachable
|
||||
? `Dashboard reachability: reachable at ${data.dashboardUrl}.`
|
||||
: `Dashboard reachability: unreachable at ${data.dashboardUrl}.`
|
||||
|
||||
if (data.degraded) {
|
||||
return `${inventorySummary} ${mappingSummary} ${reachabilitySummary} Degraded truth: the dashboard is reachable, but live OpenShell inventory is zero, so mapping alone does not prove the sandbox currently exists.${listenerSummary}${upstreamSummary}`
|
||||
}
|
||||
|
||||
if (data.reachable) {
|
||||
return `${inventorySummary} ${mappingSummary} ${data.note || reachabilitySummary}`.trim()
|
||||
}
|
||||
|
||||
return `${inventorySummary} ${mappingSummary} ${data.note || `OpenClaw Dashboard at ${data.dashboardUrl} is currently unreachable from this host.`}${listenerSummary}${upstreamSummary}`
|
||||
}
|
||||
|
||||
export default function SandboxList({
|
||||
sandboxes,
|
||||
nemoclaw,
|
||||
dashboardSessionId,
|
||||
selectedSandboxId,
|
||||
selectedSandbox,
|
||||
onSandboxSelect,
|
||||
isDestroyMode
|
||||
isDestroyMode,
|
||||
onInventoryRefresh,
|
||||
}: SandboxListProps) {
|
||||
const router = useRouter()
|
||||
const [terminalMessage, setTerminalMessage] = useState<string>('')
|
||||
const [dashboardMessage, setDashboardMessage] = useState<string>('')
|
||||
const [sandboxes, setSandboxes] = useState<Sandbox[]>([])
|
||||
const [telemetry, setTelemetry] = useState<TelemetryData>({
|
||||
cpu: 0, memory: 0, disk: 0, timestamp: new Date().toISOString()
|
||||
})
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
fetchSandboxes()
|
||||
const interval = setInterval(fetchSandboxes, 10000)
|
||||
return () => clearInterval(interval)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedSandbox) {
|
||||
if (selectedSandboxId) {
|
||||
fetchTelemetry()
|
||||
const interval = setInterval(fetchTelemetry, 5000)
|
||||
return () => clearInterval(interval)
|
||||
}
|
||||
}, [selectedSandbox])
|
||||
|
||||
const fetchSandboxes = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/telemetry/real')
|
||||
const data = await response.json()
|
||||
|
||||
const sandboxList = (data.pods?.items || [])
|
||||
.filter((pod: any) => pod.metadata?.namespace === 'agent-sandbox-system')
|
||||
.map((pod: any) => ({
|
||||
id: pod.metadata?.name || 'unknown',
|
||||
name: pod.metadata?.name || 'Unknown Sandbox',
|
||||
namespace: pod.metadata?.namespace || 'unknown',
|
||||
ip: pod.status?.podIP || 'N/A',
|
||||
status: pod.status?.phase === 'Running' ? 'running' :
|
||||
pod.status?.phase === 'Pending' ? 'pending' :
|
||||
pod.status?.phase === 'Stopped' ? 'stopped' : 'unknown' as const,
|
||||
ready: pod.status?.conditions?.find((c: any) => c.type === 'Ready')?.status === 'True'
|
||||
}))
|
||||
|
||||
setSandboxes(sandboxList)
|
||||
setLoading(false)
|
||||
} catch (error) {
|
||||
console.error('Error fetching sandboxes:', error)
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
}, [selectedSandboxId])
|
||||
|
||||
const fetchTelemetry = async () => {
|
||||
try {
|
||||
@@ -91,16 +88,6 @@ export default function SandboxList({
|
||||
}
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-64">
|
||||
<div className="text-xs text-[var(--foreground-dim)] font-mono uppercase tracking-wider">
|
||||
INITIALIZING...
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{sandboxes.length === 0 ? (
|
||||
@@ -110,7 +97,7 @@ export default function SandboxList({
|
||||
</svg>
|
||||
<h3 className="text-sm font-semibold text-[var(--foreground)] uppercase tracking-wider">No Sandboxes Detected</h3>
|
||||
<p className="text-xs text-[var(--foreground-dim)] mt-2">
|
||||
No sandboxes running in agent-sandbox-system namespace
|
||||
No live OpenShell sandboxes reported yet
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
@@ -123,7 +110,52 @@ export default function SandboxList({
|
||||
REFRESH: 10s
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
{!isDestroyMode && (
|
||||
<div className="panel p-4 space-y-2">
|
||||
<div className="flex items-center justify-between gap-4 flex-wrap">
|
||||
<div>
|
||||
<p className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">Inventory Source</p>
|
||||
<p className="text-sm font-mono text-[var(--foreground)] mt-1">Live OpenShell gateway inventory</p>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">NemoClaw Operator Surface</p>
|
||||
<p className="text-sm font-mono text-[var(--foreground)] mt-1">
|
||||
{nemoclaw?.available ? 'Local registry + services' : 'Unavailable'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-2 pt-1">
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] px-3 py-2 text-xs font-mono text-[var(--foreground-dim)]">
|
||||
Inventory visibility: {sandboxes.length} live sandbox{sandboxes.length === 1 ? '' : 'es'}
|
||||
</div>
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] px-3 py-2 text-xs font-mono text-[var(--foreground-dim)]">
|
||||
Mapping truth: intent only, not proof of sandbox existence
|
||||
</div>
|
||||
<div className={`rounded-sm border px-3 py-2 text-xs font-mono ${sandboxes.length === 0 ? 'border-[var(--status-pending)] bg-[var(--status-pending-bg)] text-[var(--status-pending)]' : 'border-[var(--border-subtle)] bg-[var(--background-tertiary)] text-[var(--foreground-dim)]'}`}>
|
||||
{sandboxes.length === 0 ? 'Truth state: degraded / unverified' : 'Truth state: verified from live inventory'}
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-xs text-[var(--foreground-dim)] font-mono">
|
||||
Dashboard session: {dashboardSessionId.slice(0, 8)}
|
||||
</p>
|
||||
{nemoclaw?.defaultSandboxNames?.length ? (
|
||||
<p className="text-xs text-[var(--foreground-dim)] font-mono">
|
||||
Default sandbox marker: {nemoclaw.defaultSandboxNames.join(', ')}
|
||||
</p>
|
||||
) : null}
|
||||
{nemoclaw?.serviceLines?.length ? (
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-2 pt-1">
|
||||
{nemoclaw.serviceLines.slice(0, 4).map((line) => (
|
||||
<div key={line} className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] px-3 py-2 text-xs font-mono text-[var(--foreground-dim)]" title={line}>
|
||||
{line}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
{sandboxes.map((sandbox) => (
|
||||
<button
|
||||
@@ -132,62 +164,81 @@ export default function SandboxList({
|
||||
className={`p-4 rounded-sm text-left transition-all border-2 ${
|
||||
isDestroyMode
|
||||
? 'border-[var(--status-stopped)] hover:bg-[var(--status-stopped-bg)]'
|
||||
: selectedSandbox === sandbox.id
|
||||
: selectedSandboxId === sandbox.id
|
||||
? 'bg-[var(--nvidia-green)] text-white border-[var(--nvidia-green)]'
|
||||
: 'panel hover:border-[var(--nvidia-green)]'
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-center justify-between mb-3">
|
||||
<span className={`text-sm font-mono font-semibold truncate ${
|
||||
isDestroyMode ? 'text-[var(--status-stopped)]' : ''
|
||||
}`}>
|
||||
{sandbox.name}
|
||||
</span>
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<span className={`text-sm font-mono font-semibold truncate ${
|
||||
isDestroyMode ? 'text-[var(--status-stopped)]' : ''
|
||||
}`}>
|
||||
{sandbox.name}
|
||||
</span>
|
||||
{sandbox.isDefault ? (
|
||||
<span className="rounded-sm border border-[var(--border-subtle)] px-1.5 py-0.5 text-[9px] uppercase tracking-wider text-[var(--foreground-dim)]">default</span>
|
||||
) : null}
|
||||
</div>
|
||||
<div className={`px-2 py-0.5 rounded-sm text-[10px] font-mono uppercase ${
|
||||
isDestroyMode
|
||||
? 'bg-[var(--status-stopped)] text-white animate-pulse'
|
||||
: sandbox.status === 'running' && sandbox.ready
|
||||
? 'bg-[var(--status-running)] text-white'
|
||||
: 'bg-[var(--status-pending)] text-white'
|
||||
: sandbox.status === 'stopped'
|
||||
? 'bg-[var(--status-stopped)] text-white'
|
||||
: sandbox.status === 'error'
|
||||
? 'bg-red-500 text-white'
|
||||
: 'bg-[var(--status-pending)] text-white'
|
||||
}`}>
|
||||
{isDestroyMode ? 'DESTROY' : sandbox.status === 'running' && sandbox.ready ? 'RUNNING' : 'PENDING'}
|
||||
{isDestroyMode ? 'DESTROY' : sandbox.status === 'running' && sandbox.ready ? 'RUNNING' : sandbox.status.toUpperCase()}
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-[10px] text-[var(--foreground-dim)] uppercase">IP Address</span>
|
||||
<span className="text-xs font-mono">{sandbox.ip}</span>
|
||||
<span className="text-[10px] text-[var(--foreground-dim)] uppercase">Attach Target</span>
|
||||
<span className="text-xs font-mono truncate max-w-[180px]" title={sandbox.ip}>{sandbox.ip}</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-[10px] text-[var(--foreground-dim)] uppercase">Namespace</span>
|
||||
<span className="text-xs font-mono truncate max-w-[120px]">{sandbox.namespace}</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<span className="text-[10px] text-[var(--foreground-dim)] uppercase">Host Alias</span>
|
||||
<span className="text-xs font-mono truncate max-w-[140px]">{sandbox.sshHostAlias || 'N/A'}</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<span className="text-[10px] text-[var(--foreground-dim)] uppercase">Sandbox ID</span>
|
||||
<span className="text-xs font-mono truncate max-w-[140px]" title={sandbox.id}>{sandbox.id}</span>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Selected Sandbox Details - Technical Data Panel */}
|
||||
{!isDestroyMode && selectedSandbox && (
|
||||
<>
|
||||
<div className="panel p-6">
|
||||
<div className="flex items-center justify-between mb-6 pb-4 border-b border-[var(--border-subtle)] gap-4 flex-wrap">
|
||||
<h4 className="text-sm font-semibold text-[var(--foreground)] uppercase tracking-wider">
|
||||
{sandboxes.find(s => s.id === selectedSandbox)?.name} — TELEMETRY
|
||||
{selectedSandbox.name} — TELEMETRY
|
||||
</h4>
|
||||
<div className="flex items-center gap-3 flex-wrap">
|
||||
<button
|
||||
onClick={async () => {
|
||||
try {
|
||||
const res = await fetch('/api/openshell/dashboard/open')
|
||||
const searchParams = new URLSearchParams()
|
||||
searchParams.set('sandboxId', selectedSandbox.id)
|
||||
searchParams.set('inventoryCount', String(sandboxes.length))
|
||||
const res = await fetch(`/api/openshell/dashboard/open?${searchParams.toString()}`)
|
||||
const data = await res.json()
|
||||
setDashboardMessage(data.loopbackOnly
|
||||
? `OpenClaw Dashboard detected at ${data.dashboardUrl}. Opening proxied dashboard route.`
|
||||
: `OpenClaw Dashboard: ${data.dashboardUrl}`)
|
||||
if (data.proxiedUrl) {
|
||||
window.open(data.proxiedUrl, '_blank', 'noopener,noreferrer')
|
||||
} else if (data.dashboardUrl && !data.loopbackOnly) {
|
||||
window.open(data.dashboardUrl, '_blank', 'noopener,noreferrer')
|
||||
setDashboardMessage(renderDashboardTruthMessage(data))
|
||||
if (data.reachable && data.launchUrl) {
|
||||
window.location.href = data.launchUrl
|
||||
} else if (data.reachable && data.proxiedUrl) {
|
||||
window.location.href = data.proxiedUrl
|
||||
} else if (data.reachable && data.dashboardUrl && !data.loopbackOnly) {
|
||||
window.location.href = data.dashboardUrl
|
||||
}
|
||||
} catch (error) {
|
||||
setDashboardMessage('Failed to resolve OpenClaw Dashboard endpoint.')
|
||||
@@ -199,55 +250,58 @@ export default function SandboxList({
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
router.push(`/operator-terminal?sandboxId=${encodeURIComponent(selectedSandbox)}`)
|
||||
const nextUrl = buildOperatorTerminalRoute({
|
||||
sandboxId: selectedSandbox.id,
|
||||
dashboardSessionId,
|
||||
})
|
||||
window.open(nextUrl, '_blank', 'noopener,noreferrer')
|
||||
}}
|
||||
className="px-3 py-2 rounded-sm bg-[var(--background-tertiary)] text-[var(--foreground)] text-xs font-mono uppercase tracking-wider hover:border-[var(--nvidia-green)] border border-[var(--border-subtle)]"
|
||||
>
|
||||
Open Operator Terminal
|
||||
Open Operator Terminal Path
|
||||
</button>
|
||||
<button
|
||||
onClick={async () => {
|
||||
await onInventoryRefresh()
|
||||
}}
|
||||
className="px-3 py-2 rounded-sm bg-[var(--background-tertiary)] text-[var(--foreground)] text-xs font-mono uppercase tracking-wider hover:border-[var(--nvidia-green)] border border-[var(--border-subtle)]"
|
||||
>
|
||||
Refresh Inventory
|
||||
</button>
|
||||
<span className="text-[10px] text-[var(--foreground-dim)] font-mono">
|
||||
LIVE
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{dashboardMessage && (
|
||||
|
||||
{(dashboardMessage || terminalMessage) && (
|
||||
<div className="mb-4 space-y-2">
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-3 text-xs text-[var(--foreground-dim)]">{dashboardMessage}</div>
|
||||
{dashboardMessage && <div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-3 text-xs text-[var(--foreground-dim)]">{dashboardMessage}</div>}
|
||||
{terminalMessage && <div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-3 text-xs text-[var(--foreground-dim)] whitespace-pre-wrap font-mono">{terminalMessage}</div>}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||
<div className="metric p-4">
|
||||
<p className="text-[10px] text-[var(--foreground-dim)] uppercase tracking-wider">CPU</p>
|
||||
<p className="text-2xl font-mono text-[var(--nvidia-green)] mt-1">
|
||||
{telemetry.cpu.toFixed(1)}%
|
||||
</p>
|
||||
<p className="text-xl font-mono text-[var(--nvidia-green)] mt-1">{telemetry.cpu.toFixed(1)}%</p>
|
||||
</div>
|
||||
<div className="metric p-4">
|
||||
<p className="text-[10px] text-[var(--foreground-dim)] uppercase tracking-wider">MEMORY</p>
|
||||
<p className="text-2xl font-mono text-[var(--nvidia-green)] mt-1">
|
||||
{telemetry.memory.toFixed(1)}%
|
||||
</p>
|
||||
<p className="text-[10px] text-[var(--foreground-dim)] uppercase tracking-wider">MEM</p>
|
||||
<p className="text-xl font-mono text-[var(--nvidia-green)] mt-1">{telemetry.memory.toFixed(1)}%</p>
|
||||
</div>
|
||||
<div className="metric p-4">
|
||||
<p className="text-[10px] text-[var(--foreground-dim)] uppercase tracking-wider">DISK</p>
|
||||
<p className="text-2xl font-mono text-[var(--nvidia-green)] mt-1">
|
||||
{telemetry.disk.toFixed(1)}%
|
||||
</p>
|
||||
<p className="text-xl font-mono text-[var(--nvidia-green)] mt-1">{telemetry.disk.toFixed(1)}%</p>
|
||||
</div>
|
||||
<div className="metric p-4">
|
||||
<p className="text-[10px] text-[var(--foreground-dim)] uppercase tracking-wider">UPDATED</p>
|
||||
<p className="text-sm font-mono text-[var(--foreground)] mt-1">{new Date(telemetry.timestamp).toLocaleTimeString()}</p>
|
||||
</div>
|
||||
{telemetry.gpuTemperature && (
|
||||
<div className="metric p-4">
|
||||
<p className="text-[10px] text-[var(--foreground-dim)] uppercase tracking-wider">GPU TEMP</p>
|
||||
<p className="text-2xl font-mono text-[var(--nvidia-green)] mt-1">
|
||||
{telemetry.gpuTemperature.toFixed(1)}°C
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ConfigurationPanel sandboxId={selectedSandbox} mode="existing" />
|
||||
<ConfigurationPanel sandboxId={selectedSandbox.id} mode="existing" onInventoryRefresh={onInventoryRefresh} />
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
|
||||
+55
-70
@@ -1,16 +1,13 @@
|
||||
"use client"
|
||||
import { useState, useEffect } from 'react'
|
||||
|
||||
interface Sandbox {
|
||||
id: string
|
||||
name: string
|
||||
ip: string
|
||||
status: 'running' | 'stopped' | 'unknown'
|
||||
}
|
||||
import type { NemoClawSummary, SandboxInventoryItem } from '../hooks/useSandboxInventory'
|
||||
|
||||
interface SidebarProps {
|
||||
hostIP: string
|
||||
selectedSandbox: string | null
|
||||
sandboxes: SandboxInventoryItem[]
|
||||
nemoclaw: NemoClawSummary | null
|
||||
dashboardSessionId: string
|
||||
selectedSandboxId: string | null
|
||||
onSandboxSelect: (id: string | null) => void
|
||||
isSubmenuOpen: boolean
|
||||
onToggleSubmenu: () => void
|
||||
@@ -26,7 +23,10 @@ interface SidebarProps {
|
||||
|
||||
export default function Sidebar({
|
||||
hostIP,
|
||||
selectedSandbox,
|
||||
sandboxes,
|
||||
nemoclaw,
|
||||
dashboardSessionId,
|
||||
selectedSandboxId,
|
||||
onSandboxSelect,
|
||||
isSubmenuOpen,
|
||||
onToggleSubmenu,
|
||||
@@ -39,49 +39,9 @@ export default function Sidebar({
|
||||
onSettingsClick,
|
||||
onExitMode
|
||||
}: SidebarProps) {
|
||||
const [sandboxes, setSandboxes] = useState<Sandbox[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
const fetchSandboxes = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/telemetry/real')
|
||||
const data = await response.json()
|
||||
|
||||
const items = data?.pods?.items || []
|
||||
if (!Array.isArray(items)) {
|
||||
setSandboxes([])
|
||||
return
|
||||
}
|
||||
|
||||
const sandboxList = items
|
||||
.filter((pod: any) => pod?.metadata?.namespace === 'agent-sandbox-system')
|
||||
.map((pod: any) => ({
|
||||
id: pod.metadata?.name || 'unknown',
|
||||
name: pod.metadata?.name || 'Unknown Sandbox',
|
||||
ip: pod.status?.podIP || 'N/A',
|
||||
status: pod.status?.phase === 'Running' ? 'running' :
|
||||
pod.status?.phase === 'Pending' ? 'pending' :
|
||||
pod.status?.phase === 'Stopped' ? 'stopped' : 'unknown' as const
|
||||
}))
|
||||
|
||||
setSandboxes(sandboxList)
|
||||
} catch (error) {
|
||||
console.error('Error fetching sandboxes in Sidebar:', error)
|
||||
setSandboxes([])
|
||||
}
|
||||
}
|
||||
|
||||
if (isSubmenuOpen || isDestroyMode || isCreateMode) {
|
||||
fetchSandboxes()
|
||||
const interval = setInterval(fetchSandboxes, 10000)
|
||||
return () => clearInterval(interval)
|
||||
}
|
||||
}, [isSubmenuOpen, isDestroyMode, isCreateMode])
|
||||
return (
|
||||
<>
|
||||
{/* Main Sidebar */}
|
||||
<aside className="fixed left-0 top-0 h-screen w-64 bg-[var(--background-secondary)] border-r border-[var(--border-subtle)] flex flex-col z-20">
|
||||
{/* Host IP Header - Industrial Style */}
|
||||
<div className="p-4 border-b border-[var(--border-subtle)]">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-8 h-8 bg-[var(--nvidia-green)] rounded-sm flex items-center justify-center">
|
||||
@@ -92,11 +52,11 @@ export default function Sidebar({
|
||||
<div>
|
||||
<p className="text-[10px] text-[var(--foreground-dim)] uppercase tracking-wider font-semibold">Host</p>
|
||||
<p className="text-sm font-mono text-[var(--nvidia-green)] tracking-tight">{hostIP}</p>
|
||||
<p className="text-[10px] text-[var(--foreground-dim)] font-mono mt-1">session {dashboardSessionId.slice(0, 8)}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Navigation Menu - Technical */}
|
||||
<nav className="flex-1 p-2">
|
||||
<button
|
||||
onClick={onToggleSubmenu}
|
||||
@@ -112,19 +72,18 @@ export default function Sidebar({
|
||||
</svg>
|
||||
<span className="text-sm font-medium tracking-tight">Sandboxes</span>
|
||||
</span>
|
||||
<svg
|
||||
className={`w-4 h-4 transition-transform ${isSubmenuOpen ? 'rotate-90' : ''}`}
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
<svg
|
||||
className={`w-4 h-4 transition-transform ${isSubmenuOpen ? 'rotate-90' : ''}`}
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
{/* Quick Actions - Technical Icons */}
|
||||
<div className="mt-4 space-y-1">
|
||||
<button
|
||||
<button
|
||||
onClick={onCreateClick}
|
||||
className={`w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors ${
|
||||
isCreateMode
|
||||
@@ -137,8 +96,8 @@ export default function Sidebar({
|
||||
</svg>
|
||||
<span className="text-sm">Create Sandbox</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
|
||||
<button
|
||||
onClick={onDestroyClick}
|
||||
className={`w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors ${
|
||||
isDestroyMode
|
||||
@@ -153,7 +112,7 @@ export default function Sidebar({
|
||||
</button>
|
||||
|
||||
{(isCreateMode || isDestroyMode) && (
|
||||
<button
|
||||
<button
|
||||
onClick={onExitMode}
|
||||
className="w-full flex items-center gap-3 px-3 py-2 rounded-sm bg-[var(--background-tertiary)] text-[var(--foreground-dim)] hover:bg-[var(--background-panel)] transition-colors"
|
||||
>
|
||||
@@ -163,27 +122,29 @@ export default function Sidebar({
|
||||
<span className="text-sm">Cancel</span>
|
||||
</button>
|
||||
)}
|
||||
|
||||
<button
|
||||
|
||||
<button
|
||||
onClick={onSettingsClick}
|
||||
className={`w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors ${
|
||||
activeView === 'settings'
|
||||
? 'bg-[var(--nvidia-green)] text-white'
|
||||
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)]'
|
||||
}`}>
|
||||
}`}
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
|
||||
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
</svg>
|
||||
<span className="text-sm">Settings</span>
|
||||
</button>
|
||||
<button
|
||||
<button
|
||||
onClick={onOverviewClick}
|
||||
className={`w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors ${
|
||||
activeView === 'overview'
|
||||
? 'bg-[var(--nvidia-green)] text-white'
|
||||
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)]'
|
||||
}`}>
|
||||
}`}
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />
|
||||
</svg>
|
||||
@@ -192,14 +153,12 @@ export default function Sidebar({
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{/* Footer - Technical */}
|
||||
<div className="p-4 border-t border-[var(--border-subtle)]">
|
||||
<p className="text-[10px] text-[var(--foreground-dim)] uppercase tracking-wider">OpenShell Control</p>
|
||||
<p className="text-[10px] text-[var(--foreground-dim)] font-mono">v1.0.0</p>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
{/* Slide-out Sandbox Submenu - Technical Data Panel */}
|
||||
<div
|
||||
className={`fixed left-64 top-0 h-screen w-72 bg-[var(--background)] border-r border-[var(--border-subtle)] transform transition-transform duration-200 ease-in-out z-10 ${
|
||||
isSubmenuOpen ? 'translate-x-0' : '-translate-x-full'
|
||||
@@ -213,6 +172,25 @@ export default function Sidebar({
|
||||
{isDestroyMode && 'SELECT A SANDBOX BELOW'}
|
||||
{!isCreateMode && !isDestroyMode && `${sandboxes.filter(s => s.status === 'running').length} RUNNING / ${sandboxes.length} TOTAL`}
|
||||
</p>
|
||||
{!isCreateMode && !isDestroyMode && (
|
||||
<div className="mt-3 rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-2">
|
||||
<p className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">Inventory Source</p>
|
||||
<p className="mt-1 text-[11px] text-[var(--foreground)] font-mono">Live OpenShell sandboxes</p>
|
||||
<p className="mt-2 text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">NemoClaw Operator</p>
|
||||
<p className="mt-1 text-[11px] text-[var(--foreground)] font-mono">
|
||||
{nemoclaw?.available ? 'Registry/service summary available' : 'No NemoClaw summary detected'}
|
||||
</p>
|
||||
<p className="mt-1 text-[10px] text-[var(--foreground-dim)] font-mono">Dashboard session: {dashboardSessionId.slice(0, 8)}</p>
|
||||
{nemoclaw?.defaultSandboxNames?.length ? (
|
||||
<p className="mt-1 text-[10px] text-[var(--foreground-dim)] font-mono">
|
||||
Default: {nemoclaw.defaultSandboxNames.join(', ')}
|
||||
</p>
|
||||
) : null}
|
||||
{nemoclaw?.serviceLines?.slice(0, 2).map((line) => (
|
||||
<p key={line} className="mt-1 text-[10px] text-[var(--foreground-dim)] font-mono truncate" title={line}>{line}</p>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="p-2 overflow-y-auto h-[calc(100vh-80px)]">
|
||||
@@ -257,7 +235,7 @@ export default function Sidebar({
|
||||
<button
|
||||
onClick={() => onSandboxSelect(null)}
|
||||
className={`w-full px-3 py-2 rounded-sm text-left transition-colors ${
|
||||
selectedSandbox === null
|
||||
selectedSandboxId === null
|
||||
? 'bg-[var(--nvidia-green)] text-white'
|
||||
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground)]'
|
||||
}`}
|
||||
@@ -275,7 +253,7 @@ export default function Sidebar({
|
||||
key={sandbox.id}
|
||||
onClick={() => onSandboxSelect(sandbox.id)}
|
||||
className={`w-full px-3 py-2 rounded-sm text-left transition-colors ${
|
||||
selectedSandbox === sandbox.id
|
||||
selectedSandboxId === sandbox.id
|
||||
? 'bg-[var(--nvidia-green)] text-white'
|
||||
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground)]'
|
||||
}`}
|
||||
@@ -286,17 +264,24 @@ export default function Sidebar({
|
||||
className={`w-2 h-2 rounded-sm ${
|
||||
sandbox.status === 'running'
|
||||
? 'bg-[var(--status-running)]'
|
||||
: 'bg-[var(--status-pending)]'
|
||||
: sandbox.status === 'stopped'
|
||||
? 'bg-[var(--status-stopped)]'
|
||||
: sandbox.status === 'error'
|
||||
? 'bg-red-500'
|
||||
: 'bg-[var(--status-pending)]'
|
||||
}`}
|
||||
/>
|
||||
<span className="text-sm font-mono truncate">{sandbox.name}</span>
|
||||
{sandbox.isDefault ? (
|
||||
<span className="rounded-sm border border-[var(--border-subtle)] px-1.5 py-0.5 text-[9px] uppercase tracking-wider text-[var(--foreground-dim)]">default</span>
|
||||
) : null}
|
||||
</div>
|
||||
<svg className="w-3 h-3 opacity-75" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</div>
|
||||
<p className="text-[10px] text-[var(--foreground-dim)] font-mono mt-1 ml-4">
|
||||
{sandbox.ip}
|
||||
{sandbox.namespace} · {sandbox.ip}
|
||||
</p>
|
||||
</button>
|
||||
))}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use client"
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useState, useEffect, useCallback } from 'react'
|
||||
import SpeedometerGauge from './SpeedometerGauge'
|
||||
|
||||
interface TelemetryData {
|
||||
@@ -36,15 +36,6 @@ export default function TelemetryDisplay() {
|
||||
fetchSandboxes()
|
||||
}, [])
|
||||
|
||||
// Fetch telemetry when sandbox changes
|
||||
useEffect(() => {
|
||||
if (selectedSandbox) {
|
||||
fetchTelemetry(selectedSandbox)
|
||||
} else {
|
||||
fetchCombinedTelemetry()
|
||||
}
|
||||
}, [selectedSandbox])
|
||||
|
||||
const fetchSandboxes = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/telemetry/real')
|
||||
@@ -64,7 +55,7 @@ export default function TelemetryDisplay() {
|
||||
}
|
||||
}
|
||||
|
||||
const fetchTelemetry = async (sandboxId: string) => {
|
||||
const fetchTelemetry = useCallback(async (sandboxId: string) => {
|
||||
try {
|
||||
const response = await fetch(`/api/telemetry/sandbox/${sandboxId}`)
|
||||
const data = await response.json()
|
||||
@@ -72,9 +63,9 @@ export default function TelemetryDisplay() {
|
||||
} catch (error) {
|
||||
console.error('Error fetching telemetry:', error)
|
||||
}
|
||||
}
|
||||
}, [])
|
||||
|
||||
const fetchCombinedTelemetry = async () => {
|
||||
const fetchCombinedTelemetry = useCallback(async () => {
|
||||
try {
|
||||
const response = await fetch('/api/telemetry/combined')
|
||||
const data = await response.json()
|
||||
@@ -82,11 +73,20 @@ export default function TelemetryDisplay() {
|
||||
} catch (error) {
|
||||
console.error('Error fetching telemetry:', error)
|
||||
}
|
||||
}, [])
|
||||
|
||||
const handleSandboxClick = (sandboxId: string | null) => {
|
||||
setSelectedSandbox(current => current === sandboxId ? null : sandboxId)
|
||||
}
|
||||
|
||||
const handleSandboxClick = (sandboxId: string) => {
|
||||
setSelectedSandbox(selectedSandbox === sandboxId ? null : sandboxId)
|
||||
}
|
||||
// Fetch telemetry when sandbox changes
|
||||
useEffect(() => {
|
||||
if (selectedSandbox) {
|
||||
fetchTelemetry(selectedSandbox)
|
||||
} else {
|
||||
fetchCombinedTelemetry()
|
||||
}
|
||||
}, [selectedSandbox, fetchTelemetry, fetchCombinedTelemetry])
|
||||
|
||||
if (loading) {
|
||||
return <div className="text-center text-gray-600 dark:text-gray-400">Loading telemetry...</div>
|
||||
@@ -165,7 +165,7 @@ export default function TelemetryDisplay() {
|
||||
</div>
|
||||
|
||||
{/* Additional Metrics */}
|
||||
{telemetry.gpuTemperature && (
|
||||
{telemetry.gpuTemperature !== undefined && telemetry.gpuMemoryUsed !== undefined && telemetry.gpuMemoryTotal !== undefined && (
|
||||
<div className="bg-white dark:bg-gray-800 rounded-lg shadow p-6">
|
||||
<h3 className="text-lg font-semibold mb-4 dark:text-white">GPU Metrics</h3>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
|
||||
Reference in New Issue
Block a user