Files
strata/apps/host/server/model-files.mjs
T
Niko1221 0b3299a019 apps/host: the owner's UI and the Node App Host
The UI source from the 14 October handoff (src/, public/, index.html, vite and
tsconfig, tests, audit-fixes, design docs) and the App Host (server/*.mjs): model
import and monitor routes, API-provider catalog and streaming (OpenAI chat, OpenAI Responses,
the Messages API), serving, tunnel, tasks, plus the host routes for Time-skip
(server/timeskip.mjs) and the tuning plan/reports. src/lib/time-skip.ts renders a real
job's own record.

The UI design is unchanged. The rebuild routed #/tuning to a new TunePanel; that is
reverted: src/screens/ModelRun.tsx and src/main.tsx are the handoff's again (#/tuning
goes where the handoff sends it), and src/components/TunePanel.tsx and
src/styles/tuning.css, which only that route used, are not carried over. Left out of
git on purpose: dist/ (build output), node_modules, and docs/evidence + docs/checkpoints
(170 MB of screenshots, kept in StrataSplit\evidence-archive).

From the owner's rebuild branch strata/rebuild-2026-10.
2026-10-15 10:24:09 +02:00

28 lines
1.2 KiB
JavaScript

/** Locate catalog weights in a Strata folder or directly inside an existing GGUF folder. */
import { closeSync, existsSync, openSync, readSync, realpathSync, statSync } from 'node:fs';
import { isAbsolute, join, relative } from 'node:path';
export function matchesGGUF(file, bytes, directory) {
let fd;
try {
if (!existsSync(file)) return false;
const path = relative(realpathSync(directory), realpathSync(file));
if (path.startsWith('..') || isAbsolute(path)) return false;
const stat = statSync(file);
if (!stat.isFile() || stat.size !== bytes) return false;
fd = openSync(file, 'r');
const magic = Buffer.alloc(4); readSync(fd, magic, 0, 4, 0);
return magic.toString() === 'GGUF';
} catch { return false; }
finally { if (fd !== undefined) closeSync(fd); }
}
export function locateModelFile(directory, model) {
const nested = join(directory, model.id, model.source.file);
if (matchesGGUF(nested, model.source.bytes, directory)) return nested;
const flat = join(directory, model.source.file);
// The design catalog deliberately has ambiguous filenames across model families.
if (!model.designOnly && matchesGGUF(flat, model.source.bytes, directory)) return flat;
return null;
}