gemmein 0.21.0 → 0.22.0
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 +30 -3
- package/lib/versions.mjs +3 -3
- package/package.json +1 -1
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
|
-
|
|
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.
|
|
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.
|
|
13
|
+
export const ENGINE_VERSION = "0.22.0";
|
|
14
14
|
|
|
15
15
|
/** file name -> hex sha256 */
|
|
16
16
|
export const ENGINE_FILES = {
|
|
17
|
-
"gemmein.js": "
|
|
18
|
-
"llms.txt": "
|
|
17
|
+
"gemmein.js": "a879aa0134b26111b291ec3cd06190dabe43d54729eba993c8943a8f398cc23b",
|
|
18
|
+
"llms.txt": "a50c1e81b3717cbb1c37a31ceec0ecc41441eb3548cda855091941558b65adfd",
|
|
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.
|
|
3
|
+
"version": "0.22.0",
|
|
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",
|