okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-split-s3: Control bundled in the installer, local engine components, no runtime acquisitionbe885026f

main
1.5 KiB31 linesraw
1/**
2 * The line between running the app and acquiring software, on the host side. It mirrors
3 * strata_control/acquisition.py: starting a model, serving, and opening the app never download or install
4 * an engine, a connector, a package or a compiler. Anything that would (the llama.cpp fetch, the cloudflared
5 * fetch) calls `require()` first, and `require()` refuses where acquiring is forbidden.
6 *
7 * Forbidden means: STRATA_NO_ACQUIRE is 1/true/yes/on, or this is the packaged app (STRATA_PACKAGED=1).
8 * The Tauri shell sets both for the host. Models the user chooses to download are a different, explicit action
9 * with its own progress and consent and do not go through here.
10 */
11
12const TRUE = new Set(['1', 'true', 'yes', 'on']);
13
14export class AcquisitionRefused extends Error {
15  constructor(what, command = 'the Terminal command `strata install`') {
16    super(`${what} is not installed here, and the app never downloads it while it runs. Install it from ${command}.`);
17    this.name = 'AcquisitionRefused';
18    this.code = 'acquisition_refused';
19    this.status = 409;
20    this.what = what;
21  }
22}
23
24export function forbidden(env = process.env) {
25  return TRUE.has(String(env.STRATA_NO_ACQUIRE ?? '').trim().toLowerCase()) || env.STRATA_PACKAGED === '1';
26}
27
28/** Call before any download or install. Throws AcquisitionRefused where acquiring is forbidden. */
29export function require(what, command, env = process.env) {
30  if (forbidden(env)) throw new AcquisitionRefused(what, command);
31}