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
+46
-7
@@ -89,8 +89,21 @@ export async function listDeployableModels(): Promise<DeployableModel[]> {
|
||||
.filter((m) => m.candidates.gguf.length > 0 || m.candidates.vllm);
|
||||
}
|
||||
|
||||
/** Bytes of the files a deployment loads (llama.cpp: the GGUF, mmproj and draft; vLLM: the repo's files). */
|
||||
export async function deploymentFileBytes(modelId: string, options: Pick<DeploymentOptions, "modelFile" | "mmproj" | "draftFile">, engine: "llama.cpp" | "vllm"): Promise<number> {
|
||||
const files = await localFiles(modelId);
|
||||
if (engine === "vllm") return modelCandidates(files).vllm?.size ?? files.reduce((s, f) => s + f.size, 0);
|
||||
const want = [options.modelFile, options.mmproj, options.draftFile].filter(Boolean);
|
||||
// A split GGUF is named by its first part; the other parts belong to it.
|
||||
const first = files.find((f) => f.path === options.modelFile);
|
||||
const group = first ? quantGroup(first.path) : null;
|
||||
return files
|
||||
.filter((f) => want.includes(f.path) || (group != null && f.path !== options.modelFile && quantGroup(f.path) === group && f.path.toLowerCase().endsWith(".gguf") && !f.path.toLowerCase().includes("mmproj")))
|
||||
.reduce((s, f) => s + f.size, 0);
|
||||
}
|
||||
|
||||
/** Check that runtime, model and files fit together; returns normalized options. */
|
||||
async function validate(input: DeploymentInput, selfId?: string): Promise<DeploymentOptions> {
|
||||
export async function validateDeployment(input: DeploymentInput, selfId?: string): Promise<DeploymentOptions> {
|
||||
const runtime = await db().query.runtimes.findFirst({ where: eq(runtimes.id, input.runtimeId) });
|
||||
if (!runtime) throw new DeploymentError("invalid", "Runtime not found.", 400);
|
||||
const model = await db().query.models.findFirst({ where: eq(models.id, input.modelId) });
|
||||
@@ -148,8 +161,12 @@ async function validate(input: DeploymentInput, selfId?: string): Promise<Deploy
|
||||
return options;
|
||||
}
|
||||
|
||||
export async function createDeployment(input: DeploymentInput, startNow: boolean) {
|
||||
const options = await validate(input);
|
||||
export async function createDeployment(
|
||||
input: DeploymentInput,
|
||||
startNow: boolean,
|
||||
agent?: { requestedBy: { tokenId: string; name: string }; startPendingApproval: boolean },
|
||||
) {
|
||||
const options = await validateDeployment(input);
|
||||
const [row] = await db()
|
||||
.insert(deployments)
|
||||
.values({
|
||||
@@ -160,7 +177,10 @@ export async function createDeployment(input: DeploymentInput, startNow: boolean
|
||||
cpus: input.cpus ?? null,
|
||||
memoryMb: input.memoryMb ?? null,
|
||||
hostPort: input.hostPort ?? null,
|
||||
desiredState: startNow ? "running" : "stopped",
|
||||
desiredState: startNow && !agent?.startPendingApproval ? "running" : "stopped",
|
||||
...(agent
|
||||
? { requestedByTokenId: agent.requestedBy.tokenId, requestedBy: agent.requestedBy.name, startRequestedAt: startNow && agent.startPendingApproval ? new Date() : null }
|
||||
: {}),
|
||||
})
|
||||
.returning({ id: deployments.id });
|
||||
return row;
|
||||
@@ -176,7 +196,7 @@ async function get(id: string) {
|
||||
export async function updateDeployment(id: string, input: DeploymentInput) {
|
||||
const d = await get(id);
|
||||
if (d.state !== "stopped" && d.state !== "failed") throw new DeploymentError("busy", "Stop the deployment before changing it.", 409);
|
||||
const options = await validate(input, id);
|
||||
const options = await validateDeployment(input, id);
|
||||
await db()
|
||||
.update(deployments)
|
||||
.set({
|
||||
@@ -193,13 +213,27 @@ export async function updateDeployment(id: string, input: DeploymentInput) {
|
||||
|
||||
export async function setDesiredState(id: string, desired: "running" | "stopped") {
|
||||
const d = await get(id);
|
||||
if (d.desiredState === desired) return;
|
||||
if (d.desiredState === desired && !d.startRequestedAt) return;
|
||||
await db()
|
||||
.update(deployments)
|
||||
.set({ desiredState: desired, ...(desired === "running" ? { error: null } : {}) })
|
||||
// Starting or stopping it by hand settles a start an agent asked for.
|
||||
.set({ desiredState: desired, startRequestedAt: null, ...(desired === "running" ? { error: null } : {}) })
|
||||
.where(eq(deployments.id, id));
|
||||
}
|
||||
|
||||
/** Mark a deployment as protected: agents can't touch it or crowd it out of VRAM. */
|
||||
export async function setProtected(id: string, value: boolean) {
|
||||
await get(id);
|
||||
await db().update(deployments).set({ protected: value }).where(eq(deployments.id, id));
|
||||
}
|
||||
|
||||
/** Turn down a start an agent asked for (the deployment stays stopped). */
|
||||
export async function rejectStart(id: string) {
|
||||
const d = await get(id);
|
||||
if (!d.startRequestedAt) throw new DeploymentError("invalid", "This deployment doesn't wait for a start approval.", 409);
|
||||
await db().update(deployments).set({ startRequestedAt: null }).where(eq(deployments.id, id));
|
||||
}
|
||||
|
||||
/** The worker stops the container and deletes the row. */
|
||||
export async function requestDelete(id: string) {
|
||||
await get(id);
|
||||
@@ -229,6 +263,11 @@ const listColumns = {
|
||||
runtimeImage: runtimes.image,
|
||||
accelerator: runtimes.accelerator,
|
||||
sweepId: deployments.sweepId,
|
||||
protected: deployments.protected,
|
||||
requestedBy: deployments.requestedBy,
|
||||
requestedByTokenId: deployments.requestedByTokenId,
|
||||
startRequestedAt: deployments.startRequestedAt,
|
||||
engineInfo: deployments.engineInfo,
|
||||
engine: runtimes.engine,
|
||||
modelId: deployments.modelId,
|
||||
repoId: models.repoId,
|
||||
|
||||
Reference in new issue
Block a user