Release 0.13.0: agent API for deployments and benchmarks
Release / release (push) Successful in 3m0s
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>
This commit is contained in:
1 parent
e007a35143
commit
716bd8f2f0
62 files changed
+6091
-219
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import { act } from "@/lib/agent-activity";
|
||||
import { ownSweep } from "@/lib/agent-runs";
|
||||
import { withToken } from "@/lib/api-tokens";
|
||||
import { v1Catch, v1Json } from "@/lib/api-v1";
|
||||
import { cancelSweep } from "@/lib/sweeps";
|
||||
|
||||
/** Cancel a sweep this token started (its current variant's deployment is removed). */
|
||||
export const POST = withToken<RouteContext<"/api/v1/sweeps/[id]/cancel">>("benchmarks:run", async (_req, { params, token }) => {
|
||||
try {
|
||||
const id = (await params).id;
|
||||
await act(token, "sweep.cancel", { type: "sweep", id }, async () => {
|
||||
await ownSweep(token, id);
|
||||
await cancelSweep(id);
|
||||
return { id };
|
||||
});
|
||||
return v1Json({ id, cancelled: true });
|
||||
} catch (err) {
|
||||
return v1Catch(err);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import { runSettled, sweepView } from "@/lib/agent-runs";
|
||||
import { withToken } from "@/lib/api-tokens";
|
||||
import { v1Catch, v1Error, v1Json } from "@/lib/api-v1";
|
||||
import { getSweep } from "@/lib/sweeps";
|
||||
import { parseWait, waitFor } from "@/lib/wait";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
/** A sweep with each variant's headline numbers and setup. ?wait=<s> (max 900) blocks until it is finished or waits for approval. */
|
||||
export const GET = withToken<RouteContext<"/api/v1/sweeps/[id]">>("benchmarks:read", async (req, { params, token }) => {
|
||||
try {
|
||||
const id = (await params).id;
|
||||
const { value, waitedS, timedOut } = await waitFor(() => getSweep(id), (s) => !s || runSettled(s.sweep.state), parseWait(new URL(req.url).searchParams), { signal: req.signal });
|
||||
if (!value) return v1Error(404, "not_found", "No sweep with this id.");
|
||||
return v1Json({ ...sweepView(value, token), ...(waitedS ? { waitedSeconds: waitedS, timedOut } : {}) });
|
||||
} catch (err) {
|
||||
return v1Catch(err);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import { act } from "@/lib/agent-activity";
|
||||
import { AgentSweepBody, requestSweep } from "@/lib/agent-runs";
|
||||
import { withToken } from "@/lib/api-tokens";
|
||||
import { v1Catch, v1Json } from "@/lib/api-v1";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
/**
|
||||
* Queue a sweep: one or two settings varied from the token's own base deployment. Each variant is
|
||||
* deployed, benchmarked and removed again, one after another.
|
||||
*/
|
||||
export const POST = withToken("benchmarks:run", async (req, { token }) => {
|
||||
try {
|
||||
const body = AgentSweepBody.parse(await req.json());
|
||||
const r = await act(token, "sweep.create", { type: "sweep" }, () => requestSweep(token, body));
|
||||
return v1Json(
|
||||
{
|
||||
...r,
|
||||
message:
|
||||
r.state === "pending_approval"
|
||||
? "Requested; it waits for the user's approval in Kaname. Don't retry or poll; tell the user and stop."
|
||||
: `Queued (${r.variants} variants, stopped after ${r.timeLimitMinutes} min); GET /api/v1/sweeps/${r.id}?wait=900 for progress.`,
|
||||
},
|
||||
201,
|
||||
);
|
||||
} catch (err) {
|
||||
return v1Catch(err);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user