gemmein 0.21.0 → 0.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/engine.mjs CHANGED
@@ -12,6 +12,11 @@ import { homedir } from "node:os";
12
12
  import { join } from "node:path";
13
13
  import { spawn } from "node:child_process";
14
14
 
15
+ /** No byte of the engine arrived for this long (connecting included): the
16
+ * download is abandoned with a sentence instead of hanging a first run. */
17
+ export const DOWNLOAD_IDLE_MS = 30_000;
18
+ const UNREACHABLE = "couldn't download the Gemmein engine — check your connection and run again";
19
+
15
20
  export function engineDir(version, base = join(homedir(), ".gemmein", "engine")) {
16
21
  return join(base, version);
17
22
  }
@@ -33,7 +38,7 @@ export function engineCached(version, files, base) {
33
38
  * A hash mismatch aborts everything — nothing unverified is ever written
34
39
  * to its final location, so nothing unverified can ever run.
35
40
  */
36
- export async function fetchEngine(version, files, downloadBase, base) {
41
+ export async function fetchEngine(version, files, downloadBase, base, { idleMs = DOWNLOAD_IDLE_MS } = {}) {
37
42
  if (Object.values(files).some((h) => !/^[a-f0-9]{64}$/.test(h))) {
38
43
  throw new Error(
39
44
  "this shim build has no released engine pinned — update the gemmein package (npm i -g gemmein@latest)"
@@ -47,9 +52,31 @@ export async function fetchEngine(version, files, downloadBase, base) {
47
52
  writeFileSync(join(dir, "package.json"), JSON.stringify({ type: "module" }) + "\n");
48
53
  for (const [name, expected] of Object.entries(files)) {
49
54
  const url = `${downloadBase}/${version}/${name}`;
50
- const res = await fetch(url);
55
+ // Every chunk that arrives restarts the clock; silence for idleMs aborts.
56
+ const stop = new AbortController();
57
+ let quiet;
58
+ const moved = () => { clearTimeout(quiet); quiet = setTimeout(() => stop.abort(), idleMs); };
59
+ let res;
60
+ const chunks = [];
61
+ try {
62
+ moved();
63
+ res = await fetch(url, { signal: stop.signal });
64
+ if (res.ok) {
65
+ const reader = res.body.getReader();
66
+ for (;;) {
67
+ moved();
68
+ const { done, value } = await reader.read();
69
+ if (done) break;
70
+ chunks.push(value);
71
+ }
72
+ }
73
+ } catch {
74
+ throw new Error(UNREACHABLE);
75
+ } finally {
76
+ clearTimeout(quiet);
77
+ }
51
78
  if (!res.ok) throw new Error(`couldn't download the Gemmein engine (${res.status} for ${name}) — check your connection and try again`);
52
- const bytes = Buffer.from(await res.arrayBuffer());
79
+ const bytes = Buffer.concat(chunks);
53
80
  const actual = sha256(bytes);
54
81
  if (actual !== expected) {
55
82
  throw new Error(
package/lib/versions.mjs CHANGED
@@ -10,12 +10,12 @@
10
10
  // fails closed: the shim refuses to download anything until a real release
11
11
  // has been promoted.
12
12
 
13
- export const ENGINE_VERSION = "0.21.0";
13
+ export const ENGINE_VERSION = "0.22.1";
14
14
 
15
15
  /** file name -> hex sha256 */
16
16
  export const ENGINE_FILES = {
17
- "gemmein.js": "ac85761c598e6257db70d50becf7e756ac5813cee98294baa395df1bae5c68d8",
18
- "llms.txt": "fd2defdc2fd879d147b5c198aac57e8983a06d2b70549a174dc6c4057b785b23",
17
+ "gemmein.js": "cf015214b36468cf047c0810a6d69dfd6c425c3e478699d69bfb95e2e0993609",
18
+ "llms.txt": "c10af7f35c60c88c931c4745be22d018880648fc5a3971fc644ee4cb17d58d8d",
19
19
  };
20
20
 
21
21
  export const DOWNLOAD_BASE = "https://downloads.gemmein.com/engine";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemmein",
3
- "version": "0.21.0",
3
+ "version": "0.22.1",
4
4
  "description": "gemmein \u2014 declare your business boundaries, prove them locally, ship. Thin launcher: downloads the Gemmein local engine, verifies it, runs it. What you read here is what runs.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,7 +15,8 @@
15
15
  "node": ">=18"
16
16
  },
17
17
  "scripts": {
18
- "test": "node --test test/*.test.mjs"
18
+ "test": "node --test test/*.test.mjs",
19
+ "prepublishOnly": "node ../../Noob-Auth/ops/process/gate.mjs release"
19
20
  },
20
21
  "keywords": [
21
22
  "backend",