feat(headroom): add extras detection and install UI (#2403)

- add Headroom extras status + install endpoints
- show Headroom version + code/ml extras in Token Saver UI
- fix Windows interpreter selection to read from env with headroom-ai
This commit is contained in:
KunN-21
2026-07-10 16:05:04 +07:00
committed by decolua
parent 90df008f0c
commit f1f9d27061
5 changed files with 368 additions and 5 deletions
+30
View File
@@ -0,0 +1,30 @@
import { NextResponse } from "next/server";
import { findPython310, getInstalledHeadroomExtras, HEADROOM_COMPRESSION_EXTRAS } from "@/lib/headroom/detect";
import { installHeadroomExtras } from "@/lib/headroom/process";
export const dynamic = "force-dynamic";
export async function GET() {
try {
const python = findPython310();
const status = getInstalledHeadroomExtras(python);
return NextResponse.json({
available: HEADROOM_COMPRESSION_EXTRAS,
...status,
});
} catch (error) {
return NextResponse.json({ error: error.message }, { status: 500 });
}
}
export async function POST(req) {
try {
const body = await req.json().catch(() => ({}));
const requested = Array.isArray(body?.extras) ? body.extras : [];
const result = await installHeadroomExtras(requested);
return NextResponse.json(result);
} catch (error) {
const status = error.code === "NOT_INSTALLED" || error.code === "NO_PYTHON" ? 400 : 500;
return NextResponse.json({ error: error.message, code: error.code || null }, { status });
}
}