Release / release (push) Successful in 3m0s
Scopes deployments:read/write and benchmarks:read/run; /api/v1 endpoints for runtimes, deployments (create with dry run, edit, start, stop, delete own ones), benchmark runs, A/B, sweeps and comparisons; ?wait= on all status endpoints. Guardrails: approval, agent deployments at once, one GPU job at a time, time limits, sweep variants, runtime and argument allowlists, host port range, memory/CPU caps, protected deployments with a VRAM check. Requested-by filters, approval bars, per-token activity log, scope editing, docs/agent/SKILL-tuning.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
101 lines
3.4 KiB
TypeScript
101 lines
3.4 KiB
TypeScript
"use client";
|
|
|
|
import { BotIcon, CheckIcon, XIcon } from "lucide-react";
|
|
import { useRouter } from "next/navigation";
|
|
import { useState } from "react";
|
|
import { approveJob, rejectJob } from "@/components/job-actions";
|
|
import { Button } from "@/components/ui/button";
|
|
import { toast } from "sonner";
|
|
import { formatBytes } from "@/lib/format";
|
|
|
|
/** A download requested through the API that waits for approval: who asked, how much, approve/reject. */
|
|
export function ApprovalBar({ job, onRemoved }: { job: { id: string; requestedBy: string | null; totalBytes: number; purpose: string | null }; onRemoved?: () => void }) {
|
|
const router = useRouter();
|
|
const [busy, setBusy] = useState(false);
|
|
|
|
async function run(fn: () => Promise<unknown>) {
|
|
setBusy(true);
|
|
try {
|
|
await fn();
|
|
router.refresh();
|
|
} finally {
|
|
setBusy(false);
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className="flex flex-col gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2.5 text-sm">
|
|
<p className="flex items-center gap-1.5">
|
|
<BotIcon className="size-4 shrink-0 text-amber-700 dark:text-amber-300" />
|
|
<span>
|
|
<strong>{job.requestedBy ?? "An API token"}</strong> asks to download {formatBytes(job.totalBytes)}
|
|
{job.purpose === "add" ? " of additional files" : ""}. It starts once you approve it.
|
|
</span>
|
|
</p>
|
|
<div className="flex gap-2">
|
|
<Button size="sm" disabled={busy} onClick={() => run(() => approveJob(job.id))}>
|
|
<CheckIcon />
|
|
Approve
|
|
</Button>
|
|
<Button
|
|
size="sm"
|
|
variant="outline"
|
|
disabled={busy}
|
|
onClick={() =>
|
|
run(async () => {
|
|
const r = await rejectJob(job.id);
|
|
if (r?.removedModel) onRemoved?.();
|
|
})
|
|
}
|
|
>
|
|
<XIcon />
|
|
Reject
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/** Something else an API token asked for (a deployment start, a run, a sweep): approve or reject. */
|
|
export function AgentApprovalBar({ requestedBy, what, base }: { requestedBy: string | null; what: string; base: string }) {
|
|
const router = useRouter();
|
|
const [busy, setBusy] = useState(false);
|
|
|
|
async function decide(kind: "approve" | "reject") {
|
|
setBusy(true);
|
|
try {
|
|
const res = await fetch(`${base}/${kind}`, { method: "POST" });
|
|
if (!res.ok) {
|
|
const body = await res.json().catch(() => ({}));
|
|
toast.error(body.error?.message ?? `Request failed (${res.status})`);
|
|
return;
|
|
}
|
|
toast.success(kind === "approve" ? "Approved" : "Rejected");
|
|
router.refresh();
|
|
} finally {
|
|
setBusy(false);
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className="flex flex-col gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2.5 text-sm">
|
|
<p className="flex items-center gap-1.5">
|
|
<BotIcon className="size-4 shrink-0 text-amber-700 dark:text-amber-300" />
|
|
<span>
|
|
<strong>{requestedBy ?? "An API token"}</strong> asks to {what}. It goes ahead once you approve it.
|
|
</span>
|
|
</p>
|
|
<div className="flex gap-2">
|
|
<Button size="sm" disabled={busy} onClick={() => decide("approve")}>
|
|
<CheckIcon />
|
|
Approve
|
|
</Button>
|
|
<Button size="sm" variant="outline" disabled={busy} onClick={() => decide("reject")}>
|
|
<XIcon />
|
|
Reject
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|