Kaname keeps two jobs: the model downloader and benchmarks. Benchmarks now run against endpoints (any OpenAI-compatible server added by URL, with an optional server-side API key and hand-written hardware notes) instead of deployments Kaname started itself. Removed: runtimes, deployments, sweeps, resource telemetry, hardware detection, the /api/v1 API with tokens and guardrails, and all Docker access. The quality eval's coding tests run in a network-less sandbox container that shares only an exchange folder with the worker. The previous state is kept in branch backup / tag backup-0.14.3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1d2f908b75
commit
276108932d
199 files changed
+5462
-15961
No files matched your search
+1
-70
@@ -1,11 +1,8 @@
|
||||
import "server-only";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { db } from "@/lib/db/client";
|
||||
import { type HardwareOverrides, settings } from "@/lib/db/schema";
|
||||
import { APPROVAL_MODES, type Guardrails, parseGuardrails } from "@/lib/agent-guardrails";
|
||||
import { parseTuning, TUNING_KEY, type TuningGuardrails } from "@/lib/agent-tuning";
|
||||
import { settings } from "@/lib/db/schema";
|
||||
import { isLabelColor } from "@/lib/colors";
|
||||
import { HARDWARE_OVERRIDES_KEY, HardwareOverrideError, parseOverrides, validateOverrides } from "@/lib/hardware";
|
||||
import { FILE_ROLE_ORDER, FILE_ROLES, type FileRole, type FileRoleStyles } from "@/lib/file-roles";
|
||||
import { MIN_SPEED_LIMIT, parseSpeedLimit, SPEED_LIMIT_KEY } from "@/lib/download-limit";
|
||||
import { DEFAULT_RECOMMENDED_ROLES, RECOMMENDABLE_ROLES } from "@/lib/recommend";
|
||||
@@ -102,69 +99,3 @@ export async function saveDownloadSpeedLimit(bytesPerSecond: number | null): Pro
|
||||
else await write(SPEED_LIMIT_KEY, Math.round(bytesPerSecond));
|
||||
return getDownloadSpeedLimit();
|
||||
}
|
||||
|
||||
const GUARDRAILS_KEY = "agent.guardrails";
|
||||
|
||||
/** Limits for downloads requested through the API (Settings → API tokens). */
|
||||
export async function getGuardrails(): Promise<Guardrails> {
|
||||
return parseGuardrails(await read<unknown>(GUARDRAILS_KEY));
|
||||
}
|
||||
|
||||
export async function saveGuardrails(input: Partial<Guardrails>): Promise<Guardrails> {
|
||||
const next = { ...(await getGuardrails()), ...input };
|
||||
if (!APPROVAL_MODES.includes(next.approvalMode)) throw new SettingsError(`Approval mode must be one of: ${APPROVAL_MODES.join(", ")}.`);
|
||||
if (!(next.maxRequestBytes >= 1_000_000)) throw new SettingsError("Max size per request must be at least 0.001 GB.");
|
||||
if (!(next.minFreeBytes >= 0)) throw new SettingsError("Minimum free space can't be negative.");
|
||||
if (!Number.isInteger(next.maxOpenJobs) || next.maxOpenJobs < 1 || next.maxOpenJobs > 50) throw new SettingsError("Max agent jobs at once must be 1–50.");
|
||||
const parsed = parseGuardrails(next);
|
||||
if (parsed.allowedAuthors.length !== next.allowedAuthors.length) throw new SettingsError("The author allowlist contains an invalid name.");
|
||||
await write(GUARDRAILS_KEY, parsed);
|
||||
return parsed;
|
||||
}
|
||||
|
||||
/** Manual hardware values (Settings → Hardware) that replace what detection reports. */
|
||||
export async function getHardwareOverrides(): Promise<HardwareOverrides> {
|
||||
return parseOverrides(await read<unknown>(HARDWARE_OVERRIDES_KEY));
|
||||
}
|
||||
|
||||
export async function saveHardwareOverrides(input: unknown): Promise<HardwareOverrides> {
|
||||
let next: HardwareOverrides;
|
||||
try {
|
||||
next = validateOverrides(input);
|
||||
} catch (err) {
|
||||
if (err instanceof HardwareOverrideError) throw new SettingsError(err.message);
|
||||
throw err;
|
||||
}
|
||||
if (Object.keys(next).length === 0) await db().delete(settings).where(eq(settings.key, HARDWARE_OVERRIDES_KEY));
|
||||
else await write(HARDWARE_OVERRIDES_KEY, next);
|
||||
return next;
|
||||
}
|
||||
|
||||
/** Limits for deployments and benchmarks requested through the API (Settings → API tokens). */
|
||||
export async function getTuning(): Promise<TuningGuardrails> {
|
||||
return parseTuning(await read<unknown>(TUNING_KEY));
|
||||
}
|
||||
|
||||
export async function saveTuning(input: Partial<TuningGuardrails>): Promise<TuningGuardrails> {
|
||||
const next = { ...(await getTuning()), ...input };
|
||||
if (!APPROVAL_MODES.includes(next.approvalMode)) throw new SettingsError(`Approval mode must be one of: ${APPROVAL_MODES.join(", ")}.`);
|
||||
const intIn = (v: number, min: number, max: number, what: string) => {
|
||||
if (!Number.isInteger(v) || v < min || v > max) throw new SettingsError(`${what} must be ${min}–${max}.`);
|
||||
};
|
||||
intIn(next.maxAgentDeployments, 1, 16, "Agent deployments at once");
|
||||
intIn(next.maxRunMinutes, 1, 24 * 60, "Max minutes per run");
|
||||
intIn(next.maxSweepMinutes, 1, 7 * 24 * 60, "Max minutes per sweep");
|
||||
intIn(next.maxSweepVariants, 2, 16, "Max sweep variants");
|
||||
const r = next.hostPortRange;
|
||||
if (r && (!Number.isInteger(r.from) || !Number.isInteger(r.to) || r.from < 1024 || r.to > 65_535 || r.from > r.to)) {
|
||||
throw new SettingsError("Host port range must be within 1024–65535, from ≤ to.");
|
||||
}
|
||||
if (next.maxMemoryMb != null && !(next.maxMemoryMb >= 256)) throw new SettingsError("Memory cap must be at least 256 MiB, or empty.");
|
||||
if (next.maxCpus != null && !(next.maxCpus >= 0.1)) throw new SettingsError("CPU cap must be at least 0.1 cores, or empty.");
|
||||
const parsed = parseTuning(next);
|
||||
for (const engine of ["llama.cpp", "vllm"] as const) {
|
||||
if (parsed.allowedArgs[engine].length !== new Set(next.allowedArgs[engine]).size) throw new SettingsError(`The ${engine} argument allowlist contains something that isn't a flag.`);
|
||||
}
|
||||
await write(TUNING_KEY, parsed);
|
||||
return parsed;
|
||||
}
|
||||
Reference in new issue
Block a user