Milestone (b): repo lookup and file selection

- Hub API client: resolve revision to SHA, paginated recursive file tree,
  gated-access probe, readable error mapping
- Add-model page with quant quick-select, fnmatch-compatible include/exclude
  globs, selection summary and free-space hint
- Models stored pinned to the reviewed SHA with full file list and selection rule
- Library list, model detail page, remove (never-downloaded models only)
- Worker reports MODELS_DIR free space; unit tests for selection logic

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-10-05 15:39:45 +02:00
1 parent 891e496157
commit 8f7ac60ccf
35 files changed
+2567 -19

No files matched your search

+20 -5
View File
@@ -1,4 +1,5 @@
import { execFile } from "node:child_process";
import { mkdir, statfs } from "node:fs/promises";
import { promisify } from "node:util";
import { inArray } from "drizzle-orm";
import { db } from "@/lib/db/client";
@@ -38,20 +39,34 @@ async function recoverInterruptedJobs() {
log.warn(`marked ${stale.length} job(s) as interrupted`);
}
async function diskSpace(dir: string) {
try {
const s = await statfs(dir);
return { modelsDirFreeBytes: s.bavail * s.bsize, modelsDirTotalBytes: s.blocks * s.bsize };
} catch {
return { modelsDirFreeBytes: null, modelsDirTotalBytes: null };
}
}
async function heartbeat(startedAt: Date, hfVersion: string | null) {
const now = new Date();
const values = {
pid: process.pid,
hfVersion,
startedAt,
heartbeatAt: now,
...(await diskSpace(coreEnv().MODELS_DIR)),
};
await db()
.insert(workerState)
.values({ id: "worker", pid: process.pid, hfVersion, startedAt, heartbeatAt: now })
.onConflictDoUpdate({
target: workerState.id,
set: { pid: process.pid, hfVersion, startedAt, heartbeatAt: now },
});
.values({ id: "worker", ...values })
.onConflictDoUpdate({ target: workerState.id, set: values });
}
async function main() {
const env = coreEnv();
log.info(`starting (pid ${process.pid}), models dir: ${env.MODELS_DIR}`);
await mkdir(env.MODELS_DIR, { recursive: true });
await runMigrations();
log.info("database migrated");