Files
Kaname/src/app/api/settings/tuning/route.ts
T
Pascal LinxweilerandClaude Opus 5.5 716bd8f2f0
Release / release (push) Successful in 3m0s
Release 0.13.0: agent API for deployments and benchmarks
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>
2026-10-21 15:11:06 +02:00

36 lines
1.3 KiB
TypeScript

import { NextResponse } from "next/server";
import { z } from "zod";
import { APPROVAL_MODES } from "@/lib/agent-guardrails";
import { withAuth } from "@/lib/api-auth";
import { apiError, handleApiError } from "@/lib/api-errors";
import { getTuning, saveTuning, SettingsError } from "@/lib/settings";
export const dynamic = "force-dynamic";
/** Guardrails for deployments and benchmarks requested through the API. */
export const GET = withAuth(async () => NextResponse.json(await getTuning()));
const Body = z
.object({
approvalMode: z.enum(APPROVAL_MODES),
maxAgentDeployments: z.number().int(),
maxRunMinutes: z.number().int(),
maxSweepMinutes: z.number().int(),
maxSweepVariants: z.number().int(),
allowedRuntimeIds: z.array(z.string().max(64)).max(100),
allowedArgs: z.object({ "llama.cpp": z.array(z.string().max(80)).max(500), vllm: z.array(z.string().max(80)).max(500) }),
hostPortRange: z.object({ from: z.number().int(), to: z.number().int() }).nullable(),
maxMemoryMb: z.number().nullable(),
maxCpus: z.number().nullable(),
})
.partial();
export const PUT = withAuth(async (req) => {
try {
return NextResponse.json(await saveTuning(Body.parse(await req.json())));
} catch (err) {
if (err instanceof SettingsError) return apiError(err.status, err.code, err.message);
return handleApiError(err);
}
});