Add OpenShell Control auth and installer
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
"use client"
|
||||
|
||||
import type { ReactNode } from "react"
|
||||
|
||||
export default function AuthShell({
|
||||
title,
|
||||
description,
|
||||
children,
|
||||
}: {
|
||||
title: string
|
||||
description: string
|
||||
children: ReactNode
|
||||
}) {
|
||||
return (
|
||||
<main className="min-h-screen bg-[var(--background)] text-[var(--foreground)] flex items-center justify-center p-6">
|
||||
<section className="panel w-full max-w-md p-8 space-y-6">
|
||||
<div className="space-y-2">
|
||||
<div className="w-9 h-9 bg-[var(--nvidia-green)] rounded-sm flex items-center justify-center">
|
||||
<svg className="w-5 h-5 text-black" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M12 11V7a4 4 0 00-8 0v4m12 0V7a4 4 0 00-8 0m-2 4h12v10H6V11z" />
|
||||
</svg>
|
||||
</div>
|
||||
<h1 className="text-lg font-semibold uppercase tracking-wider text-[var(--foreground)]">{title}</h1>
|
||||
<p className="text-xs text-[var(--foreground-dim)]">{description}</p>
|
||||
</div>
|
||||
{children}
|
||||
</section>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
@@ -27,6 +27,8 @@ interface ConfigurationPanelProps {
|
||||
sandboxId: string
|
||||
mode?: 'existing' | 'create'
|
||||
onCreateSuccess?: (sandboxId: string) => void | Promise<void>
|
||||
embedded?: boolean
|
||||
showHeader?: boolean
|
||||
}
|
||||
|
||||
function FieldHelp({ text }: { text: string }) {
|
||||
@@ -74,7 +76,7 @@ function blocksToPolicy(blocks: NetworkPolicyBlock[]): OpenShellPolicy["network_
|
||||
return out
|
||||
}
|
||||
|
||||
export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCreateSuccess }: ConfigurationPanelProps) {
|
||||
export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCreateSuccess, embedded = false, showHeader = true }: ConfigurationPanelProps) {
|
||||
const [policy, setPolicy] = useState<OpenShellPolicy>(defaultPolicy)
|
||||
const [blocks, setBlocks] = useState<NetworkPolicyBlock[]>([])
|
||||
const [loading, setLoading] = useState(mode === 'existing')
|
||||
@@ -153,21 +155,24 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre
|
||||
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">
|
||||
{mode === 'create' ? 'New Sandbox' : `${sandboxId} — OpenShell Policy`}
|
||||
</h4>
|
||||
<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>
|
||||
<div className={embedded ? "" : "panel p-6 mt-6 border-t-2 border-[var(--nvidia-green)]"}>
|
||||
{showHeader && (
|
||||
<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' ? 'New Sandbox' : `${sandboxId} - OpenShell Policy`}
|
||||
</h4>
|
||||
<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>
|
||||
)}
|
||||
{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 template and enter a sandbox name.</p></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></button>)}</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' : '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</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>
|
||||
{mode === 'existing' && <section className="space-y-3"><h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Policy JSON</h5><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></section>}
|
||||
{!showHeader && <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>}
|
||||
{message && <div className="text-sm text-[var(--foreground-dim)] whitespace-pre-wrap">{message}</div>}
|
||||
</div>}
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
"use client"
|
||||
|
||||
import { useMemo, useState } from "react"
|
||||
import type { SandboxInventoryItem } from "../hooks/useSandboxInventory"
|
||||
|
||||
export default function SandboxFilesPanel({
|
||||
sandbox,
|
||||
embedded = false,
|
||||
showHeader = true,
|
||||
}: {
|
||||
sandbox: SandboxInventoryItem
|
||||
embedded?: boolean
|
||||
showHeader?: boolean
|
||||
}) {
|
||||
const [selectedFile, setSelectedFile] = useState<File | null>(null)
|
||||
const [uploadPath, setUploadPath] = useState("/sandbox/")
|
||||
const [downloadPath, setDownloadPath] = useState("/sandbox/")
|
||||
const [busy, setBusy] = useState<"upload" | "download" | null>(null)
|
||||
const [message, setMessage] = useState("")
|
||||
|
||||
const suggestedUploadPath = useMemo(() => {
|
||||
if (!selectedFile) return uploadPath
|
||||
return uploadPath.endsWith("/") ? `${uploadPath}${selectedFile.name}` : uploadPath
|
||||
}, [selectedFile, uploadPath])
|
||||
|
||||
async function uploadFile() {
|
||||
if (!selectedFile || busy) return
|
||||
try {
|
||||
setBusy("upload")
|
||||
setMessage("")
|
||||
const form = new FormData()
|
||||
form.set("file", selectedFile)
|
||||
form.set("path", uploadPath)
|
||||
const response = await fetch(`/api/sandbox/${encodeURIComponent(sandbox.id)}/files/upload`, {
|
||||
method: "POST",
|
||||
body: form,
|
||||
})
|
||||
const data = await response.json()
|
||||
if (!response.ok) throw new Error(data.error || "Failed to upload file")
|
||||
setMessage(data.note || `Uploaded to ${data.uploaded?.path || suggestedUploadPath}.`)
|
||||
setDownloadPath(data.uploaded?.path || suggestedUploadPath)
|
||||
} catch (error) {
|
||||
setMessage(error instanceof Error ? error.message : "Failed to upload file")
|
||||
} finally {
|
||||
setBusy(null)
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadFile() {
|
||||
if (!downloadPath.trim() || busy) return
|
||||
try {
|
||||
setBusy("download")
|
||||
setMessage("")
|
||||
const response = await fetch(`/api/sandbox/${encodeURIComponent(sandbox.id)}/files/download?${new URLSearchParams({ path: downloadPath.trim() })}`)
|
||||
if (!response.ok) {
|
||||
const data = await response.json().catch(() => ({}))
|
||||
throw new Error(data.error || "Failed to download file")
|
||||
}
|
||||
|
||||
const blob = await response.blob()
|
||||
const contentDisposition = response.headers.get("content-disposition") || ""
|
||||
const fileName = decodeURIComponent(contentDisposition.match(/filename\*=UTF-8''([^;]+)/)?.[1] || "")
|
||||
|| contentDisposition.match(/filename="([^"]+)"/)?.[1]
|
||||
|| downloadPath.split("/").filter(Boolean).pop()
|
||||
|| "download.bin"
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const anchor = document.createElement("a")
|
||||
anchor.href = url
|
||||
anchor.download = fileName
|
||||
document.body.appendChild(anchor)
|
||||
anchor.click()
|
||||
anchor.remove()
|
||||
window.URL.revokeObjectURL(url)
|
||||
setMessage(`Downloaded ${downloadPath.trim()}.`)
|
||||
} catch (error) {
|
||||
setMessage(error instanceof Error ? error.message : "Failed to download file")
|
||||
} finally {
|
||||
setBusy(null)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={embedded ? "" : "panel p-6"}>
|
||||
{showHeader && (
|
||||
<div className="flex items-center justify-between gap-4 border-b border-[var(--border-subtle)] pb-4">
|
||||
<div>
|
||||
<h4 className="text-sm font-semibold text-[var(--foreground)] uppercase tracking-wider">
|
||||
{sandbox.name} - FILE TRANSFER
|
||||
</h4>
|
||||
<p className="mt-1 text-xs text-[var(--foreground-dim)]">
|
||||
Move files through scoped sandbox paths.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className={`${showHeader ? "mt-5" : ""} grid grid-cols-1 lg:grid-cols-2 gap-5`}>
|
||||
<section className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4 space-y-4">
|
||||
<div>
|
||||
<h5 className="text-xs font-semibold uppercase tracking-wider text-[var(--foreground)]">Upload</h5>
|
||||
<p className="mt-1 text-xs text-[var(--foreground-dim)]">Destination must be under /sandbox or /tmp.</p>
|
||||
</div>
|
||||
<input
|
||||
type="file"
|
||||
onChange={(event) => setSelectedFile(event.target.files?.[0] || null)}
|
||||
className="block w-full text-xs text-[var(--foreground-dim)] file:mr-3 file:rounded-sm file:border file:border-[var(--border-subtle)] file:bg-[var(--background)] file:px-3 file:py-2 file:text-xs file:font-mono file:uppercase file:text-[var(--foreground)]"
|
||||
/>
|
||||
<div className="space-y-2">
|
||||
<label className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">Destination Path</label>
|
||||
<input
|
||||
value={uploadPath}
|
||||
onChange={(event) => setUploadPath(event.target.value)}
|
||||
placeholder="/sandbox/file.txt"
|
||||
className="w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] px-3 py-2 text-xs font-mono text-[var(--foreground)] focus:outline-none focus:border-[var(--nvidia-green)]"
|
||||
/>
|
||||
{selectedFile && (
|
||||
<p className="text-[11px] font-mono text-[var(--foreground-dim)]">Target: {suggestedUploadPath}</p>
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
onClick={uploadFile}
|
||||
disabled={!selectedFile || busy !== null}
|
||||
className="px-4 py-2 rounded-sm bg-[var(--nvidia-green)] text-white text-xs font-mono uppercase tracking-wider disabled:opacity-50"
|
||||
>
|
||||
{busy === "upload" ? "Uploading..." : "Upload File"}
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<section className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4 space-y-4">
|
||||
<div>
|
||||
<h5 className="text-xs font-semibold uppercase tracking-wider text-[var(--foreground)]">Download</h5>
|
||||
<p className="mt-1 text-xs text-[var(--foreground-dim)]">Enter a regular file path under /sandbox or /tmp.</p>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<label className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">Source Path</label>
|
||||
<input
|
||||
value={downloadPath}
|
||||
onChange={(event) => setDownloadPath(event.target.value)}
|
||||
placeholder="/sandbox/file.txt"
|
||||
className="w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] px-3 py-2 text-xs font-mono text-[var(--foreground)] focus:outline-none focus:border-[var(--nvidia-green)]"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
onClick={downloadFile}
|
||||
disabled={!downloadPath.trim() || busy !== null}
|
||||
className="px-4 py-2 rounded-sm bg-[var(--background)] text-[var(--foreground)] text-xs font-mono uppercase tracking-wider hover:border-[var(--nvidia-green)] border border-[var(--border-subtle)] disabled:opacity-50"
|
||||
>
|
||||
{busy === "download" ? "Downloading..." : "Download File"}
|
||||
</button>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{message && (
|
||||
<div className="mt-4 rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-3 text-xs text-[var(--foreground-dim)] whitespace-pre-wrap">
|
||||
{message}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -54,7 +54,15 @@ function dedupeRoutes(routes: SandboxInferenceRoute[]) {
|
||||
.map((route) => [route.id || routeKey(route), { ...route, id: route.id || routeKey(route) }])).values())
|
||||
}
|
||||
|
||||
export default function SandboxInferencePanel({ sandbox }: { sandbox: SandboxInventoryItem }) {
|
||||
export default function SandboxInferencePanel({
|
||||
sandbox,
|
||||
embedded = false,
|
||||
showHeader = true,
|
||||
}: {
|
||||
sandbox: SandboxInventoryItem
|
||||
embedded?: boolean
|
||||
showHeader?: boolean
|
||||
}) {
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [applying, setApplying] = useState(false)
|
||||
@@ -221,29 +229,42 @@ export default function SandboxInferencePanel({ sandbox }: { sandbox: SandboxInv
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="panel p-6">
|
||||
<div className="flex items-center justify-between gap-4 border-b border-[var(--border-subtle)] pb-4">
|
||||
<div>
|
||||
<h4 className="text-sm font-semibold text-[var(--foreground)] uppercase tracking-wider">
|
||||
{sandbox.name} - INFERENCE ROUTES
|
||||
</h4>
|
||||
<p className="mt-1 text-xs text-[var(--foreground-dim)]">
|
||||
Enable multiple endpoint/model routes for this sandbox.
|
||||
</p>
|
||||
<div className={embedded ? "" : "panel p-6"}>
|
||||
{showHeader && (
|
||||
<div className="flex items-center justify-between gap-4 border-b border-[var(--border-subtle)] pb-4">
|
||||
<div>
|
||||
<h4 className="text-sm font-semibold text-[var(--foreground)] uppercase tracking-wider">
|
||||
{sandbox.name} - INFERENCE ROUTES
|
||||
</h4>
|
||||
<p className="mt-1 text-xs text-[var(--foreground-dim)]">
|
||||
Enable multiple endpoint/model routes for this sandbox.
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={load}
|
||||
disabled={loading || saving}
|
||||
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)] disabled:opacity-50"
|
||||
>
|
||||
Refresh
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
onClick={load}
|
||||
disabled={loading || saving}
|
||||
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)] disabled:opacity-50"
|
||||
>
|
||||
Refresh
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{loading ? (
|
||||
<div className="py-8 text-xs uppercase tracking-wider text-[var(--foreground-dim)]">Loading inference routes...</div>
|
||||
) : (
|
||||
<div className="mt-5 space-y-5">
|
||||
<div className={`${showHeader ? "mt-5" : ""} space-y-5`}>
|
||||
{!showHeader && (
|
||||
<div className="flex justify-end">
|
||||
<button
|
||||
onClick={load}
|
||||
disabled={loading || saving}
|
||||
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)] disabled:opacity-50"
|
||||
>
|
||||
Refresh
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{primaryRoute && (
|
||||
<div className="metric p-4">
|
||||
<p className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">Primary Route</p>
|
||||
|
||||
+322
-89
@@ -1,9 +1,10 @@
|
||||
"use client"
|
||||
import { useEffect, useState } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import ConfigurationPanel from './ConfigurationPanel'
|
||||
import SandboxFilesPanel from './SandboxFilesPanel'
|
||||
import SandboxInferencePanel from './SandboxInferencePanel'
|
||||
import type { NemoClawSummary, SandboxInventoryItem } from '../hooks/useSandboxInventory'
|
||||
import { buildOperatorTerminalRoute } from '../lib/dashboardSession'
|
||||
|
||||
interface TelemetryData {
|
||||
cpu: number
|
||||
@@ -18,7 +19,6 @@ interface TelemetryData {
|
||||
interface SandboxListProps {
|
||||
sandboxes: SandboxInventoryItem[]
|
||||
nemoclaw: NemoClawSummary | null
|
||||
dashboardSessionId: string
|
||||
selectedSandboxId: string | null
|
||||
selectedSandbox: SandboxInventoryItem | null
|
||||
onSandboxSelect: (id: string | null) => void
|
||||
@@ -26,6 +26,25 @@ interface SandboxListProps {
|
||||
onInventoryRefresh: () => Promise<SandboxInventoryItem[]>
|
||||
}
|
||||
|
||||
type DrawerKey = 'operations' | 'files' | 'inference' | 'policy'
|
||||
type NetworkRuleRequest = {
|
||||
chunkId: string
|
||||
status: string
|
||||
rule: string
|
||||
binary: string
|
||||
confidence: string
|
||||
rationale: string
|
||||
endpoints: string[]
|
||||
binaries: string[]
|
||||
}
|
||||
type PermissionFeed = {
|
||||
latest?: { status?: string; chunkId?: string; error?: string } | null
|
||||
pending?: NetworkRuleRequest[]
|
||||
recent?: NetworkRuleRequest[]
|
||||
pendingCount?: number
|
||||
rejectedCount?: number
|
||||
}
|
||||
|
||||
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.'
|
||||
@@ -39,19 +58,70 @@ function openDashboardUrl(url: string, openInNewTab: boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
function DrawerSection({
|
||||
title,
|
||||
summary,
|
||||
open,
|
||||
onToggle,
|
||||
children,
|
||||
}: {
|
||||
title: string
|
||||
summary: string
|
||||
open: boolean
|
||||
onToggle: () => void
|
||||
children: ReactNode
|
||||
}) {
|
||||
return (
|
||||
<section className="panel overflow-hidden">
|
||||
<button
|
||||
type="button"
|
||||
onClick={onToggle}
|
||||
aria-expanded={open}
|
||||
className="flex w-full items-center justify-between gap-4 p-5 text-left"
|
||||
>
|
||||
<div className="min-w-0">
|
||||
<h4 className="text-sm font-semibold text-[var(--foreground)] uppercase tracking-wider">{title}</h4>
|
||||
<p className="mt-1 text-xs text-[var(--foreground-dim)]">{summary}</p>
|
||||
</div>
|
||||
<svg
|
||||
className={`h-4 w-4 shrink-0 text-[var(--foreground-dim)] transition-transform ${open ? 'rotate-90' : ''}`}
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</button>
|
||||
{open && (
|
||||
<div className="border-t border-[var(--border-subtle)] p-6">
|
||||
{children}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default function SandboxList({
|
||||
sandboxes,
|
||||
nemoclaw: _nemoclaw,
|
||||
dashboardSessionId,
|
||||
selectedSandboxId,
|
||||
selectedSandbox,
|
||||
onSandboxSelect,
|
||||
isDestroyMode,
|
||||
onInventoryRefresh,
|
||||
}: SandboxListProps) {
|
||||
const [terminalMessage, setTerminalMessage] = useState<string>('')
|
||||
const [dashboardMessage, setDashboardMessage] = useState<string>('')
|
||||
const [restartInProgress, setRestartInProgress] = useState(false)
|
||||
const [permissionMessage, setPermissionMessage] = useState('')
|
||||
const [permissionFeeds, setPermissionFeeds] = useState<Record<string, PermissionFeed>>({})
|
||||
const [grantingSandboxId, setGrantingSandboxId] = useState<string | null>(null)
|
||||
const [openDrawers, setOpenDrawers] = useState<Record<DrawerKey, boolean>>({
|
||||
operations: true,
|
||||
files: false,
|
||||
inference: false,
|
||||
policy: false,
|
||||
})
|
||||
const [telemetry, setTelemetry] = useState<TelemetryData>({
|
||||
cpu: 0, memory: 0, disk: 0, timestamp: new Date().toISOString()
|
||||
})
|
||||
@@ -64,6 +134,34 @@ export default function SandboxList({
|
||||
}
|
||||
}, [selectedSandboxId])
|
||||
|
||||
useEffect(() => {
|
||||
if (sandboxes.length === 0) {
|
||||
setPermissionFeeds({})
|
||||
return
|
||||
}
|
||||
|
||||
let active = true
|
||||
const loadPermissionFeeds = async () => {
|
||||
const entries = await Promise.all(sandboxes.map(async (sandbox) => {
|
||||
try {
|
||||
const response = await fetch(`/api/sandbox/${encodeURIComponent(sandbox.id)}/permissions`, { cache: 'no-store' })
|
||||
const data = await response.json()
|
||||
return [sandbox.id, response.ok ? data.feed : { rejectedCount: 1, latest: { status: 'Unavailable', error: data.error } }] as const
|
||||
} catch (error) {
|
||||
return [sandbox.id, { rejectedCount: 1, latest: { status: 'Unavailable', error: error instanceof Error ? error.message : 'Permission feed unavailable' } }] as const
|
||||
}
|
||||
}))
|
||||
if (active) setPermissionFeeds(Object.fromEntries(entries))
|
||||
}
|
||||
|
||||
loadPermissionFeeds()
|
||||
const interval = window.setInterval(loadPermissionFeeds, 12000)
|
||||
return () => {
|
||||
active = false
|
||||
window.clearInterval(interval)
|
||||
}
|
||||
}, [sandboxes])
|
||||
|
||||
const fetchTelemetry = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/telemetry/combined')
|
||||
@@ -93,6 +191,33 @@ export default function SandboxList({
|
||||
}
|
||||
}
|
||||
|
||||
const toggleDrawer = (key: DrawerKey) => {
|
||||
setOpenDrawers((current) => ({ ...current, [key]: !current[key] }))
|
||||
}
|
||||
|
||||
const resolvePermissionRequest = async (sandbox: SandboxInventoryItem, action: 'approve' | 'reject', chunkId: string) => {
|
||||
if (!chunkId) return
|
||||
try {
|
||||
setGrantingSandboxId(sandbox.id)
|
||||
setPermissionMessage(`${action === 'approve' ? 'Approving' : 'Rejecting'} network request for ${sandbox.name}...`)
|
||||
const response = await fetch(`/api/sandbox/${encodeURIComponent(sandbox.id)}/permissions`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ action, chunkId }),
|
||||
})
|
||||
const data = await response.json()
|
||||
if (!response.ok) throw new Error(data.error || 'Failed to resolve permission request')
|
||||
if (data.result?.feed) {
|
||||
setPermissionFeeds((current) => ({ ...current, [sandbox.id]: data.result.feed }))
|
||||
}
|
||||
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')
|
||||
} finally {
|
||||
setGrantingSandboxId(null)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{sandboxes.length === 0 ? (
|
||||
@@ -118,9 +243,8 @@ export default function SandboxList({
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
{sandboxes.map((sandbox) => (
|
||||
<button
|
||||
<div
|
||||
key={sandbox.id}
|
||||
onClick={() => onSandboxSelect(sandbox.id)}
|
||||
className={`p-4 rounded-sm text-left transition-all border-2 ${
|
||||
isDestroyMode
|
||||
? 'border-[var(--status-stopped)] hover:bg-[var(--status-stopped-bg)]'
|
||||
@@ -129,60 +253,105 @@ export default function SandboxList({
|
||||
: 'panel hover:border-[var(--nvidia-green)]'
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-center justify-between mb-3">
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<span className={`text-sm font-mono font-semibold truncate ${
|
||||
isDestroyMode ? 'text-[var(--status-stopped)]' : ''
|
||||
<button type="button" onClick={() => onSandboxSelect(sandbox.id)} className="w-full text-left">
|
||||
<div className="flex items-center justify-between mb-3">
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
{(() => {
|
||||
const feed = permissionFeeds[sandbox.id]
|
||||
const needsAttention = Boolean((feed?.pendingCount || 0) > 0 || /pending|fail|error|unavailable/i.test(feed?.latest?.status || ''))
|
||||
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`}>
|
||||
<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>
|
||||
</span>
|
||||
) : (
|
||||
<span className="h-2.5 w-2.5 rounded-full bg-[var(--status-running)]" title={`Policy status: ${feed?.latest?.status || 'ok'}`} />
|
||||
)
|
||||
})()}
|
||||
<span className={`text-sm font-mono font-semibold truncate ${
|
||||
isDestroyMode ? 'text-[var(--status-stopped)]' : ''
|
||||
}`}>
|
||||
{sandbox.name}
|
||||
</span>
|
||||
{sandbox.isDefault ? (
|
||||
<span className={`rounded-sm border px-1.5 py-0.5 text-[9px] uppercase tracking-wider ${selectedSandboxId === sandbox.id && !isDestroyMode ? 'border-black/30 text-black' : 'border-[var(--border-subtle)] 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'
|
||||
: sandbox.status === 'stopped'
|
||||
? 'bg-[var(--status-stopped)] text-white'
|
||||
: sandbox.status === 'error'
|
||||
? 'bg-red-500 text-white'
|
||||
: 'bg-[var(--status-pending)] text-white'
|
||||
}`}>
|
||||
{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}
|
||||
{isDestroyMode ? 'DESTROY' : sandbox.status === 'running' && sandbox.ready ? 'RUNNING' : sandbox.status.toUpperCase()}
|
||||
</div>
|
||||
</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'
|
||||
: 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' : sandbox.status.toUpperCase()}
|
||||
|
||||
<div className="space-y-1">
|
||||
{([
|
||||
['Attach Target', sandbox.ip, '180px'],
|
||||
['Namespace', sandbox.namespace, '120px'],
|
||||
['Host Alias', sandbox.sshHostAlias || 'N/A', '140px'],
|
||||
['Sandbox ID', sandbox.id, '140px'],
|
||||
] as Array<[string, string, string]>).map(([label, value, width]) => (
|
||||
<div key={label} className="flex items-center justify-between gap-3">
|
||||
<span className={`text-[10px] uppercase ${selectedSandboxId === sandbox.id && !isDestroyMode ? 'text-black' : 'text-[var(--foreground-dim)]'}`}>{label}</span>
|
||||
<span className={`text-xs font-mono truncate ${selectedSandboxId === sandbox.id && !isDestroyMode ? 'text-black' : ''}`} style={{ maxWidth: width }} title={value}>{value}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</button>
|
||||
<div className="mt-3 pt-3 border-t border-black/10">
|
||||
<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={`w-full rounded-sm border px-3 py-2 text-xs font-mono uppercase tracking-wider focus:outline-none ${selectedSandboxId === sandbox.id && !isDestroyMode ? 'border-black/30 bg-white/30 text-black' : 'border-[var(--border-subtle)] bg-[var(--background-tertiary)] text-[var(--foreground)]'}`}
|
||||
>
|
||||
<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>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center justify-between">
|
||||
<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>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{permissionMessage && (
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-3 text-xs text-[var(--foreground-dim)]">
|
||||
{permissionMessage}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!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">
|
||||
{selectedSandbox.name} — TELEMETRY
|
||||
</h4>
|
||||
<DrawerSection
|
||||
title={`${selectedSandbox.name} - Operations`}
|
||||
summary="Dashboard, terminal, restart, refresh, and live telemetry."
|
||||
open={openDrawers.operations}
|
||||
onToggle={() => toggleDrawer('operations')}
|
||||
>
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-center gap-3 flex-wrap">
|
||||
<button
|
||||
onClick={async () => {
|
||||
@@ -215,18 +384,6 @@ export default function SandboxList({
|
||||
>
|
||||
{restartInProgress ? 'Restarting Sandbox...' : 'Restart Sandbox'}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
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
|
||||
</button>
|
||||
<button
|
||||
onClick={async () => {
|
||||
await onInventoryRefresh()
|
||||
@@ -239,38 +396,114 @@ export default function SandboxList({
|
||||
LIVE
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{(dashboardMessage || terminalMessage) && (
|
||||
<div className="mb-4 space-y-2">
|
||||
{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>
|
||||
)}
|
||||
{dashboardMessage && (
|
||||
<div className="space-y-2">
|
||||
{dashboardMessage && <div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-3 text-xs text-[var(--foreground-dim)]">{dashboardMessage}</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-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">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-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 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-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">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-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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DrawerSection>
|
||||
|
||||
<SandboxInferencePanel sandbox={selectedSandbox} />
|
||||
<DrawerSection
|
||||
title="File Transfer"
|
||||
summary="Upload files into the sandbox and download files back out."
|
||||
open={openDrawers.files}
|
||||
onToggle={() => toggleDrawer('files')}
|
||||
>
|
||||
<SandboxFilesPanel sandbox={selectedSandbox} embedded showHeader={false} />
|
||||
</DrawerSection>
|
||||
|
||||
<ConfigurationPanel sandboxId={selectedSandbox.id} mode="existing" />
|
||||
<DrawerSection
|
||||
title="Inference Routes"
|
||||
summary="Configure and apply provider/model routes for this sandbox."
|
||||
open={openDrawers.inference}
|
||||
onToggle={() => toggleDrawer('inference')}
|
||||
>
|
||||
<SandboxInferencePanel sandbox={selectedSandbox} embedded showHeader={false} />
|
||||
</DrawerSection>
|
||||
|
||||
<DrawerSection
|
||||
title="Sandbox Policy"
|
||||
summary="Approve or reject network requests raised by the sandbox."
|
||||
open={openDrawers.policy}
|
||||
onToggle={() => toggleDrawer('policy')}
|
||||
>
|
||||
<div className="space-y-4">
|
||||
{(() => {
|
||||
const feed = permissionFeeds[selectedSandbox.id]
|
||||
const pending = feed?.pending || []
|
||||
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)]">
|
||||
No pending network permission requests for this sandbox.
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return pending.map((request) => (
|
||||
<div key={request.chunkId} className="rounded-sm border border-amber-400/60 bg-amber-400/10 p-4">
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<div className="min-w-0 space-y-2">
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<span className="text-xs font-mono font-semibold text-[var(--foreground)]">
|
||||
{request.endpoints.join(', ') || request.rule}
|
||||
</span>
|
||||
{request.confidence ? (
|
||||
<span className="rounded-sm border border-[var(--border-subtle)] px-1.5 py-0.5 text-[10px] text-[var(--foreground-dim)]">
|
||||
{request.confidence}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<p className="text-xs text-[var(--foreground-dim)]">{request.rationale || 'Sandbox requested a network policy rule.'}</p>
|
||||
<p className="text-[10px] font-mono text-[var(--foreground-dim)]">
|
||||
{request.binary || request.binaries.join(', ') || 'unknown binary'} / {request.chunkId}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
disabled={grantingSandboxId === selectedSandbox.id}
|
||||
onClick={() => resolvePermissionRequest(selectedSandbox, 'approve', request.chunkId)}
|
||||
className="rounded-sm border border-[var(--nvidia-green)] bg-[var(--nvidia-green)] px-3 py-2 text-xs font-mono uppercase tracking-wider text-black disabled:opacity-50"
|
||||
>
|
||||
Grant
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
disabled={grantingSandboxId === selectedSandbox.id}
|
||||
onClick={() => resolvePermissionRequest(selectedSandbox, 'reject', 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)] disabled:opacity-50"
|
||||
>
|
||||
Reject
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
})()}
|
||||
<ConfigurationPanel sandboxId={selectedSandbox.id} mode="existing" embedded showHeader={false} />
|
||||
</div>
|
||||
</DrawerSection>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
|
||||
@@ -9,8 +9,11 @@ interface SidebarProps {
|
||||
onSandboxesClick: () => void
|
||||
onCreateClick: () => void
|
||||
onDestroyClick: () => void
|
||||
onTerminalClick: () => void
|
||||
onSettingsClick: () => void
|
||||
onExitMode: () => void
|
||||
onLogout: () => void
|
||||
terminalDisabled?: boolean
|
||||
}
|
||||
|
||||
export default function Sidebar({
|
||||
@@ -22,8 +25,11 @@ export default function Sidebar({
|
||||
onSandboxesClick,
|
||||
onCreateClick,
|
||||
onDestroyClick,
|
||||
onTerminalClick,
|
||||
onSettingsClick,
|
||||
onExitMode,
|
||||
onLogout,
|
||||
terminalDisabled = false,
|
||||
}: SidebarProps) {
|
||||
return (
|
||||
<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">
|
||||
@@ -87,6 +93,17 @@ export default function Sidebar({
|
||||
<span className="text-sm">Destroy Sandbox</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={onTerminalClick}
|
||||
disabled={terminalDisabled}
|
||||
className="mt-1 w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)] disabled:opacity-40 disabled:cursor-not-allowed"
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M4 17l6-6-6-6m8 14h8" />
|
||||
</svg>
|
||||
<span className="text-sm">Operator Terminal</span>
|
||||
</button>
|
||||
|
||||
{(isCreateMode || isDestroyMode) && (
|
||||
<button
|
||||
onClick={onExitMode}
|
||||
@@ -112,7 +129,29 @@ export default function Sidebar({
|
||||
</svg>
|
||||
<span className="text-sm">Inference Endpoints</span>
|
||||
</button>
|
||||
|
||||
<a
|
||||
href="/setup-account"
|
||||
className="mt-1 w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)]"
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M12 12a4 4 0 100-8 4 4 0 000 8zm-7 9a7 7 0 0114 0" />
|
||||
</svg>
|
||||
<span className="text-sm">Setup Account</span>
|
||||
</a>
|
||||
</nav>
|
||||
|
||||
<div className="p-2 border-t border-[var(--border-subtle)]">
|
||||
<button
|
||||
onClick={onLogout}
|
||||
className="w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)]"
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M15 12H3m0 0l4-4m-4 4l4 4m5-10h6v12h-6" />
|
||||
</svg>
|
||||
<span className="text-sm">Sign Out</span>
|
||||
</button>
|
||||
</div>
|
||||
</aside>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user