@animastor/installer 0.2.9 → 0.2.10
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/README.md +12 -1
- package/ai/install-manifests/audio/qwen-tts.json +2 -1
- package/ai/install-manifests/image/qwen-image.json +5 -4
- package/ai/install-manifests/video/ltx-2.3.json +2 -1
- package/package.json +1 -1
- package/src/installer/cli.js +24 -0
- package/src/installer/engine/engine.js +28 -6
- package/src/installer/engine/worker.js +124 -11
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ published to npm as `@animastor/installer`.
|
|
|
14
14
|
|
|
15
15
|
```
|
|
16
16
|
packages/animastor-installer/
|
|
17
|
-
├── package.json @animastor/installer 0.2.
|
|
17
|
+
├── package.json @animastor/installer 0.2.10, Node >=20, zero runtime deps
|
|
18
18
|
├── src/installer/
|
|
19
19
|
│ ├── cli.js CLI entry (detect/plan/install/verify/resume/uninstall)
|
|
20
20
|
│ ├── index.js Public API entry (10 exports, incl. setupContract)
|
|
@@ -187,6 +187,17 @@ path (`doctor --yes`, no TTY) only starts a stopped worker. An unchanged
|
|
|
187
187
|
`.env` is no longer rewritten. `doctor` and `status` print
|
|
188
188
|
`current job: none|<id>`.
|
|
189
189
|
|
|
190
|
+
The worker bundle is deployed WHOLE (0.2.10): every file of the source — the
|
|
191
|
+
hub bundle or the installer's bundled copy — is copied, not only
|
|
192
|
+
`manifest.worker_bundle.files` (that list is the minimal presence check; `.env`
|
|
193
|
+
and `.env.*` other than `.env.example`, `node_modules/`, `.git/`, `logs/` are
|
|
194
|
+
never copied). The deployed file list is recorded in install-state
|
|
195
|
+
(`components.worker.bundle_files`); the next update removes the files of the
|
|
196
|
+
old version the new bundle no longer ships (only recorded files, never `.env`
|
|
197
|
+
or `node-classes.json`; a 0.2.9 state falls back to `files_installed`). Before
|
|
198
|
+
a start every local `require('./…')` reachable from `worker.cjs` must exist,
|
|
199
|
+
otherwise the start is FAILED naming the file and the worker is not spawned.
|
|
200
|
+
|
|
190
201
|
Every install/doctor run first brings the management tools (`animastor`,
|
|
191
202
|
the persistent installer copy) and an installed worker bundle to its own
|
|
192
203
|
version — before any check that can end the run — so every printed fix
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": "1.0.0",
|
|
3
|
-
"revision": "2026.
|
|
3
|
+
"revision": "2026.11.07-r1",
|
|
4
4
|
"status": "ready",
|
|
5
5
|
"profile": {
|
|
6
6
|
"id": "audio/qwen-tts",
|
|
@@ -338,6 +338,7 @@
|
|
|
338
338
|
"worker-cleanup.cjs",
|
|
339
339
|
"worker-cleanup-journal.cjs",
|
|
340
340
|
"job-protocol-v2.cjs",
|
|
341
|
+
"worker-logs.cjs",
|
|
341
342
|
"package.json",
|
|
342
343
|
"package-lock.json",
|
|
343
344
|
".env.example"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": "1.0.0",
|
|
3
|
-
"revision": "2026.11.07-
|
|
3
|
+
"revision": "2026.11.07-r2",
|
|
4
4
|
"status": "ready",
|
|
5
5
|
"profile": {
|
|
6
6
|
"id": "image/qwen-image",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"note": "Workflows are the single source of truth for 'required'. Connectors are backend-only execution metadata and are NOT installed. Runtime audits are reference only, never the source of truth. Legacy old_img-qwen-image.json is excluded by the workflow loader and must not influence this manifest (it references a different CLIP quant — Q4_K_M instead of Q8_0)."
|
|
22
22
|
},
|
|
23
23
|
"hardware": {
|
|
24
|
-
"gpu_min_vram_gb":
|
|
25
|
-
"basis": "
|
|
24
|
+
"gpu_min_vram_gb": 14,
|
|
25
|
+
"basis": "minimum_supported",
|
|
26
26
|
"reference_gpu": "NVIDIA L40S (46068 MiB)",
|
|
27
|
-
"
|
|
27
|
+
"derivation": "Estimate, not a measured floor (installer 0.2.10): img-qwen-image samples with the GGUF UNet qwen-image-2512-Q4_K_M (12.33 GiB) and the 4-step LoRA (1.10 GiB) resident together, plus activations at 768x1024; ComfyUI moves the Qwen2.5-VL-7B Q8_0 text encoder (7.54 GiB) out of VRAM after encoding. 14 GB keeps 16 GB cards (15.6-16 GiB as reported) in; 12 GB cards are below. Known to run on L40S 46 GB. Lower it only after a measured run on a smaller card."
|
|
28
28
|
},
|
|
29
29
|
"runtime_requirements": {
|
|
30
30
|
"comfyui": {
|
|
@@ -329,6 +329,7 @@
|
|
|
329
329
|
"worker-cleanup.cjs",
|
|
330
330
|
"worker-cleanup-journal.cjs",
|
|
331
331
|
"job-protocol-v2.cjs",
|
|
332
|
+
"worker-logs.cjs",
|
|
332
333
|
"package.json",
|
|
333
334
|
"package-lock.json",
|
|
334
335
|
".env.example"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": "1.0.0",
|
|
3
|
-
"revision": "2026.11.07-
|
|
3
|
+
"revision": "2026.11.07-r2",
|
|
4
4
|
"status": "ready",
|
|
5
5
|
"profile": {
|
|
6
6
|
"id": "video/ltx-2.3",
|
|
@@ -744,6 +744,7 @@
|
|
|
744
744
|
"worker-cleanup.cjs",
|
|
745
745
|
"worker-cleanup-journal.cjs",
|
|
746
746
|
"job-protocol-v2.cjs",
|
|
747
|
+
"worker-logs.cjs",
|
|
747
748
|
"package.json",
|
|
748
749
|
"package-lock.json",
|
|
749
750
|
".env.example"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@animastor/installer",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"description": "Animastor Private GPU Worker installer — self-contained CLI and library for GPU worker setup, verification, and management.",
|
|
5
5
|
"main": "src/installer/index.js",
|
|
6
6
|
"exports": {
|
package/src/installer/cli.js
CHANGED
|
@@ -874,6 +874,28 @@ function nodeDepsFailedResult({ gate, mode }) {
|
|
|
874
874
|
};
|
|
875
875
|
}
|
|
876
876
|
|
|
877
|
+
/** installer 0.2.10: install-state worker.bundle_files (fallback files_installed) of THIS dir, or null. */
|
|
878
|
+
function previousBundleFilesFromState(io, statePath, workerDir) {
|
|
879
|
+
try {
|
|
880
|
+
const st = stateStore.loadState(io, statePath);
|
|
881
|
+
return engineMod.previousBundleFilesOf(st && st.components && st.components.worker, workerDir);
|
|
882
|
+
} catch (_) { return null; }
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/** After a bundle update: record the new bundle file list and the copied files; drop removed ones. */
|
|
886
|
+
function recordWorkerBundle(io, statePath, workerDir, res) {
|
|
887
|
+
try {
|
|
888
|
+
const st = stateStore.loadState(io, statePath);
|
|
889
|
+
const w = st && st.components && st.components.worker;
|
|
890
|
+
if (!w || !w.dir || path.resolve(w.dir) !== path.resolve(workerDir)) return false;
|
|
891
|
+
const removed = new Set(res.files_removed || []);
|
|
892
|
+
w.files_installed = [...new Set([...(w.files_installed || []), ...(res.files_installed || [])])].filter((f) => !removed.has(f));
|
|
893
|
+
if (Array.isArray(res.bundle_files)) w.bundle_files = res.bundle_files.slice();
|
|
894
|
+
stateStore.saveState(io, statePath, st, io.now);
|
|
895
|
+
return true;
|
|
896
|
+
} catch (_) { return false; }
|
|
897
|
+
}
|
|
898
|
+
|
|
877
899
|
/**
|
|
878
900
|
* Register a file the installer wrote into the worker dir (uninstall removes
|
|
879
901
|
* it). Only for the recorded worker of THIS dir; no-op without a state.
|
|
@@ -1037,7 +1059,9 @@ async function preflightSelfUpdate(io, {
|
|
|
1037
1059
|
try {
|
|
1038
1060
|
out.bundle = await engineMod.refreshInstalledWorkerBundle(io, {
|
|
1039
1061
|
workerDir, manifest: manifests[0], repoRoot, hubUrl, log: logger, nodeBin,
|
|
1062
|
+
previousBundleFiles: previousBundleFilesFromState(io, statePath, workerDir),
|
|
1040
1063
|
});
|
|
1064
|
+
if (out.bundle && out.bundle.status === 'updated') recordWorkerBundle(io, statePath, workerDir, out.bundle);
|
|
1041
1065
|
} catch (err) {
|
|
1042
1066
|
out.bundle = { status: 'failed', reason: err.message };
|
|
1043
1067
|
}
|
|
@@ -978,6 +978,7 @@ async function runInstallation(args) {
|
|
|
978
978
|
httpFetchText: null, log,
|
|
979
979
|
update: decisions.apply_fixes !== false,
|
|
980
980
|
nodeBin,
|
|
981
|
+
previousBundleFiles: previousBundleFilesOf(st.components.worker, workerDir),
|
|
981
982
|
}));
|
|
982
983
|
} finally {
|
|
983
984
|
if (bundleTmp) {
|
|
@@ -989,12 +990,19 @@ async function runInstallation(args) {
|
|
|
989
990
|
if (bundleRes.ok && bundleRes.value.status === 'installed') {
|
|
990
991
|
// Ownership is per-file: a pre-existing worker dir keeps its
|
|
991
992
|
// own files; only what the installer copied is registered.
|
|
993
|
+
const prevW = st.components.worker && st.components.worker.dir
|
|
994
|
+
&& path.resolve(st.components.worker.dir) === path.resolve(workerDir) ? st.components.worker : null;
|
|
995
|
+
const removedSet = new Set(bundleRes.value.files_removed || []);
|
|
992
996
|
st.components.worker = {
|
|
993
|
-
|
|
997
|
+
// a re-run over the installer's own dir keeps its ownership and earlier files
|
|
998
|
+
owned: bundleRes.value.dir_created === true || (prevW ? prevW.owned === true : false),
|
|
994
999
|
dir: workerDir,
|
|
995
|
-
files_installed: bundleRes.value.files_installed || []
|
|
1000
|
+
files_installed: [...new Set([...(prevW ? prevW.files_installed || [] : []), ...(bundleRes.value.files_installed || [])])]
|
|
1001
|
+
.filter((f) => !removedSet.has(f)),
|
|
996
1002
|
files_kept: bundleRes.value.files_kept || [],
|
|
997
|
-
|
|
1003
|
+
// installer 0.2.10: the deployed bundle's file list — the next update removes what it no longer ships
|
|
1004
|
+
bundle_files: bundleRes.value.bundle_files || [],
|
|
1005
|
+
env_created: prevW ? (prevW.env_created ?? null) : null, // finalized by the .env step below
|
|
998
1006
|
};
|
|
999
1007
|
}
|
|
1000
1008
|
state.setArtifact(st, w.id, bundleRes.ok && bundleRes.value.status === 'installed' ? 'installed' : 'failed');
|
|
@@ -1315,7 +1323,20 @@ async function runInstallation(args) {
|
|
|
1315
1323
|
* behind). A missing installation is left to the regular install step.
|
|
1316
1324
|
* @returns {Promise<{ status: 'absent'|'current'|'unknown'|'updated'|'failed', have: string|null, want: string|null, files_installed?: string[], reason?: string }>}
|
|
1317
1325
|
*/
|
|
1318
|
-
|
|
1326
|
+
/**
|
|
1327
|
+
* installer 0.2.10: the file list of the bundle version on disk, as recorded in
|
|
1328
|
+
* install-state (worker.bundle_files). Installs by 0.2.9 and older recorded only
|
|
1329
|
+
* files_installed (manifest files they copied) — that list is the fallback.
|
|
1330
|
+
* null when the state does not describe THIS worker dir.
|
|
1331
|
+
*/
|
|
1332
|
+
function previousBundleFilesOf(w, workerDir) {
|
|
1333
|
+
if (!w || !w.dir || !workerDir || path.resolve(w.dir) !== path.resolve(workerDir)) return null;
|
|
1334
|
+
if (Array.isArray(w.bundle_files)) return w.bundle_files.slice();
|
|
1335
|
+
if (Array.isArray(w.files_installed)) return w.files_installed.filter((f) => f !== worker.NODE_CLASSES_FILE);
|
|
1336
|
+
return null;
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
async function refreshInstalledWorkerBundle(io, { workerDir, manifest, repoRoot = null, hubUrl = null, log = null, nodeBin = null, previousBundleFiles = null }) {
|
|
1319
1340
|
if (!workerDir || !manifest || !io.fs.existsSync(path.join(workerDir, 'worker.cjs'))) return { status: 'absent', have: null, want: null };
|
|
1320
1341
|
const srcDir = repoBundleSource.resolveRepoBundleDir(io.fs, repoRoot);
|
|
1321
1342
|
const have = worker.readPkgVersion(io, workerDir);
|
|
@@ -1338,11 +1359,11 @@ async function refreshInstalledWorkerBundle(io, { workerDir, manifest, repoRoot
|
|
|
1338
1359
|
if (fetched.bundleDir) { bundleDir = fetched.bundleDir; bundleTmp = fetched.tmpDir; }
|
|
1339
1360
|
else return { status: 'failed', have, want, reason: `worker bundle fetch failed: ${fetched.reason}` };
|
|
1340
1361
|
}
|
|
1341
|
-
const r = worker.installWorkerBundle(io, { workerDir, manifest, repoRoot, bundleDir, hubUrl, httpFetchText: null, log, update: true, nodeBin });
|
|
1362
|
+
const r = worker.installWorkerBundle(io, { workerDir, manifest, repoRoot, bundleDir, hubUrl, httpFetchText: null, log, update: true, nodeBin, previousBundleFiles });
|
|
1342
1363
|
if (r.status !== 'installed') return { status: 'failed', have, want, reason: r.reason || r.status };
|
|
1343
1364
|
const now = worker.readPkgVersion(io, workerDir);
|
|
1344
1365
|
if (now !== want) return { status: 'failed', have, want, reason: `bundle is ${now} after the update, expected ${want}` };
|
|
1345
|
-
return { status: 'updated', have, want, files_installed: r.files_installed || [] };
|
|
1366
|
+
return { status: 'updated', have, want, files_installed: r.files_installed || [], bundle_files: r.bundle_files || [], files_removed: r.files_removed || [] };
|
|
1346
1367
|
} catch (err) {
|
|
1347
1368
|
return { status: 'failed', have, want, reason: err.message };
|
|
1348
1369
|
} finally {
|
|
@@ -1712,6 +1733,7 @@ module.exports = {
|
|
|
1712
1733
|
autoPickComfyPort,
|
|
1713
1734
|
platformComfyMissingChecks,
|
|
1714
1735
|
refreshInstalledWorkerBundle,
|
|
1736
|
+
previousBundleFilesOf,
|
|
1715
1737
|
writeNodeClasses: worker.writeNodeClasses,
|
|
1716
1738
|
desiredEnvWiring,
|
|
1717
1739
|
endToEndChecks,
|
|
@@ -103,9 +103,53 @@ function ensureWorkerDependencies(io, { workerDir, nodeBin = null }) {
|
|
|
103
103
|
* already on disk and were kept (files_kept).
|
|
104
104
|
* @returns {{ status, files, files_installed, files_kept, dir_created, updated_from?, reason? }}
|
|
105
105
|
*/
|
|
106
|
-
|
|
106
|
+
// ── installer 0.2.10: the bundle source is copied WHOLE ─────────────────────
|
|
107
|
+
// 0.2.9 copied only manifest.worker_bundle.files; bundle 2.4.1 added
|
|
108
|
+
// worker-logs.cjs (required by worker.cjs) → «Cannot find module
|
|
109
|
+
// './worker-logs.cjs'» after an update. The source dir (hub bundle or the
|
|
110
|
+
// installer's bundled copy) IS the bundle: every regular file is deployed;
|
|
111
|
+
// the manifest list is only the minimal presence check. Never copied: .env
|
|
112
|
+
// and .env.* (except .env.example), node_modules/, .git/, logs/.
|
|
113
|
+
const BUNDLE_SKIP_DIRS = new Set(['node_modules', '.git', 'logs']);
|
|
114
|
+
/** Files of a bundle that are never removed as «stale» (user data / installer-written). */
|
|
115
|
+
const BUNDLE_PROTECTED = new Set(['.env', 'node-classes.json']);
|
|
116
|
+
|
|
117
|
+
/** io.fs.statSync returns booleans; node fs returns methods — accept both. */
|
|
118
|
+
function statIs(st, what) {
|
|
119
|
+
if (!st) return false;
|
|
120
|
+
const v = st[what];
|
|
121
|
+
return typeof v === 'function' ? v.call(st) === true : v === true;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function isBundleFile(relPath) {
|
|
125
|
+
const base = relPath.split('/').pop();
|
|
126
|
+
if (base === '.env' || /^\.env\..+$/.test(base)) return base === '.env.example';
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Sorted relative paths of every deployable file of a bundle dir. */
|
|
131
|
+
function listBundleFiles(io, dir) {
|
|
132
|
+
const out = [];
|
|
133
|
+
const walk = (rel) => {
|
|
134
|
+
const abs = rel ? path.join(dir, rel) : dir;
|
|
135
|
+
let names;
|
|
136
|
+
try { names = io.fs.readdirSync(abs); } catch (_) { return; }
|
|
137
|
+
for (const name of names) {
|
|
138
|
+
const r = rel ? `${rel}/${name}` : name;
|
|
139
|
+
const p = path.join(dir, r);
|
|
140
|
+
let st;
|
|
141
|
+
try { st = io.fs.statSync(p); } catch (_) { continue; }
|
|
142
|
+
if (statIs(st, 'isDirectory')) { if (!BUNDLE_SKIP_DIRS.has(name)) walk(r); continue; }
|
|
143
|
+
if (statIs(st, 'isFile') && isBundleFile(r)) out.push(r);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
walk('');
|
|
147
|
+
return out.sort();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function installWorkerBundle(io, { workerDir, manifest, repoRoot = null, bundleDir = null, hubUrl = null, httpFetchText = null, log = null, update = true, nodeBin = null, previousBundleFiles = null }) {
|
|
107
151
|
const wb = manifest.worker_bundle || {};
|
|
108
|
-
const
|
|
152
|
+
const manifestFiles = wb.files || [];
|
|
109
153
|
const dirCreated = !io.fs.existsSync(workerDir);
|
|
110
154
|
if (dirCreated) io.fs.mkdirSync(workerDir, { recursive: true });
|
|
111
155
|
|
|
@@ -118,17 +162,22 @@ function installWorkerBundle(io, { workerDir, manifest, repoRoot = null, bundleD
|
|
|
118
162
|
const installed = [];
|
|
119
163
|
const kept = [];
|
|
120
164
|
const failed = [];
|
|
165
|
+
const removed = [];
|
|
121
166
|
|
|
122
|
-
|
|
167
|
+
// every file of the source bundle(s), manifest-listed or not; a file only
|
|
168
|
+
// the hub bundle has (repo copy partial) still comes from the hub bundle
|
|
169
|
+
const sources = [fromRepo ? repoBundleDir : null, bundleDir].filter(Boolean);
|
|
170
|
+
const sourceOf = new Map();
|
|
171
|
+
for (const dir of sources) for (const f of listBundleFiles(io, dir)) if (!sourceOf.has(f)) sourceOf.set(f, dir);
|
|
172
|
+
const bundleFiles = [...new Set([...sourceOf.keys(), ...manifestFiles])].sort();
|
|
173
|
+
|
|
174
|
+
for (const f of bundleFiles) {
|
|
123
175
|
const dest = path.join(workerDir, f);
|
|
124
176
|
if (io.fs.existsSync(dest) && !outdated) { kept.push(f); continue; }
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
if (bundleDir && io.fs.existsSync(path.join(bundleDir, f))) {
|
|
131
|
-
io.fs.copyFileSync(path.join(bundleDir, f), dest);
|
|
177
|
+
const src = sourceOf.get(f);
|
|
178
|
+
if (src) {
|
|
179
|
+
io.fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
180
|
+
io.fs.copyFileSync(path.join(src, f), dest);
|
|
132
181
|
installed.push(f);
|
|
133
182
|
continue;
|
|
134
183
|
}
|
|
@@ -136,10 +185,28 @@ function installWorkerBundle(io, { workerDir, manifest, repoRoot = null, bundleD
|
|
|
136
185
|
failed.push(f);
|
|
137
186
|
}
|
|
138
187
|
|
|
188
|
+
// minimal presence check: everything the manifest names must be on disk
|
|
189
|
+
const missing = manifestFiles.filter((f) => !io.fs.existsSync(path.join(workerDir, f)));
|
|
190
|
+
for (const f of missing) if (!failed.includes(f)) failed.push(f);
|
|
139
191
|
if (failed.length > 0) {
|
|
140
192
|
return { status: 'failed', files: installed, files_installed: installed, files_kept: kept, dir_created: dirCreated, reason: `could not obtain bundle files: ${failed.join(', ')} (no repo checkout, no hub bundle)` };
|
|
141
193
|
}
|
|
142
194
|
|
|
195
|
+
// an UPDATE removes the files of the previous bundle version that the new
|
|
196
|
+
// one no longer ships — only files the installer itself recorded
|
|
197
|
+
// (install-state worker.bundle_files), never .env / node-classes.json
|
|
198
|
+
if (outdated && Array.isArray(previousBundleFiles) && sources.length > 0) {
|
|
199
|
+
const now = new Set(bundleFiles);
|
|
200
|
+
for (const f of previousBundleFiles) {
|
|
201
|
+
if (typeof f !== 'string' || !f || now.has(f) || BUNDLE_PROTECTED.has(f) || f.includes('..') || path.isAbsolute(f)) continue;
|
|
202
|
+
const p = path.join(workerDir, f);
|
|
203
|
+
try {
|
|
204
|
+
if (io.fs.existsSync(p) && statIs(io.fs.statSync(p), 'isFile')) { io.fs.unlinkSync(p); removed.push(f); }
|
|
205
|
+
} catch (_) { /* best effort */ }
|
|
206
|
+
}
|
|
207
|
+
if (removed.length && log) log.info(`worker bundle: removed ${removed.length} file(s) of ${installedVersion} not in ${sourceVersion}: ${removed.join(', ')}`);
|
|
208
|
+
}
|
|
209
|
+
|
|
143
210
|
const deps = ensureWorkerDependencies(io, { workerDir, nodeBin });
|
|
144
211
|
if (deps.ran && log) log.info(`worker dependencies installed (${deps.deps.join(', ')})`);
|
|
145
212
|
|
|
@@ -149,6 +216,9 @@ function installWorkerBundle(io, { workerDir, manifest, repoRoot = null, bundleD
|
|
|
149
216
|
}
|
|
150
217
|
return {
|
|
151
218
|
status: 'installed', files: installed, files_installed: installed, files_kept: kept, dir_created: dirCreated,
|
|
219
|
+
// install-state worker.bundle_files: what the NEXT update may remove as stale
|
|
220
|
+
bundle_files: sources.length > 0 ? bundleFiles : (Array.isArray(previousBundleFiles) ? previousBundleFiles : bundleFiles),
|
|
221
|
+
files_removed: removed,
|
|
152
222
|
version: readPkgVersion(io, workerDir),
|
|
153
223
|
...(outdated ? { updated_from: installedVersion } : {}),
|
|
154
224
|
};
|
|
@@ -331,9 +401,50 @@ async function verifyRegistration(io, { hubUrl, token, expectedType = null }) {
|
|
|
331
401
|
* DECLARES (the canonical bundle declares none — the old hard-coded
|
|
332
402
|
* node-fetch probe made every zero-dependency install "unstartable").
|
|
333
403
|
*/
|
|
404
|
+
const LOCAL_REQUIRE_RE = /require\(\s*(["'])(\.{1,2}\/[^"']+)\1\s*\)/g;
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* installer 0.2.10: every local `require('./…')` reachable from worker.cjs
|
|
408
|
+
* must exist on disk — otherwise the worker dies at start with «Cannot find
|
|
409
|
+
* module» (bundle 2.4.1 / worker-logs.cjs). Pure over io.fs.
|
|
410
|
+
* @returns {string[]} missing modules as written in the source (e.g. './worker-logs.cjs')
|
|
411
|
+
*/
|
|
412
|
+
function missingLocalRequires(io, workerDir, entry = 'worker.cjs') {
|
|
413
|
+
const missing = [];
|
|
414
|
+
const seen = new Set();
|
|
415
|
+
const queue = [path.join(workerDir, entry)];
|
|
416
|
+
const resolve = (from, spec) => {
|
|
417
|
+
const base = path.resolve(path.dirname(from), spec);
|
|
418
|
+
for (const c of [base, `${base}.js`, `${base}.cjs`, `${base}.json`, path.join(base, 'index.js')]) {
|
|
419
|
+
try { if (io.fs.existsSync(c) && statIs(io.fs.statSync(c), 'isFile')) return c; } catch (_) { /* next */ }
|
|
420
|
+
}
|
|
421
|
+
return null;
|
|
422
|
+
};
|
|
423
|
+
while (queue.length) {
|
|
424
|
+
const file = queue.shift();
|
|
425
|
+
if (seen.has(file)) continue;
|
|
426
|
+
seen.add(file);
|
|
427
|
+
let src;
|
|
428
|
+
try { src = io.fs.readFileSync(file, 'utf8'); } catch (_) { continue; }
|
|
429
|
+
if (typeof src !== 'string') src = String(src);
|
|
430
|
+
LOCAL_REQUIRE_RE.lastIndex = 0;
|
|
431
|
+
let m;
|
|
432
|
+
while ((m = LOCAL_REQUIRE_RE.exec(src)) !== null) {
|
|
433
|
+
const hit = resolve(file, m[2]);
|
|
434
|
+
if (!hit) { if (!missing.includes(m[2])) missing.push(m[2]); continue; }
|
|
435
|
+
if (/\.(c?js)$/.test(hit) && path.resolve(hit).startsWith(path.resolve(workerDir))) queue.push(hit);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return missing;
|
|
439
|
+
}
|
|
440
|
+
|
|
334
441
|
function checkWorkerCanStart(io, { workerDir, nodeBin = 'node' }) {
|
|
335
442
|
const workerCjs = path.join(workerDir, 'worker.cjs');
|
|
336
443
|
if (!io.fs.existsSync(workerCjs)) return { ok: false, reason: 'worker.cjs missing' };
|
|
444
|
+
const missing = missingLocalRequires(io, workerDir);
|
|
445
|
+
if (missing.length > 0) {
|
|
446
|
+
return { ok: false, reason: `worker bundle incomplete: ${missing.join(', ')} missing in ${workerDir} (required by worker.cjs) — re-run the installer to redeploy the bundle`, missing };
|
|
447
|
+
}
|
|
337
448
|
const syntax = io.exec(nodeBin, ['--check', workerCjs]);
|
|
338
449
|
if (syntax.code !== 0) return { ok: false, reason: `worker.cjs failed syntax check: ${String(syntax.stderr).slice(-200)}` };
|
|
339
450
|
const deps = Object.keys(declaredDependencies(io, workerDir));
|
|
@@ -449,7 +560,7 @@ function workerProcessStartMs(io, { workerDir, pid, platformAdapter = null }) {
|
|
|
449
560
|
|
|
450
561
|
/** Files whose change requires a worker restart: .env and the bundle (installer 0.2.8). */
|
|
451
562
|
const WORKER_CONFIG_FILES = Object.freeze(['.env', 'package.json', 'worker.cjs', 'worker-env.cjs',
|
|
452
|
-
'job-protocol-v2.cjs', 'worker-cleanup.cjs', 'worker-cleanup-journal.cjs']);
|
|
563
|
+
'job-protocol-v2.cjs', 'worker-cleanup.cjs', 'worker-cleanup-journal.cjs', 'worker-logs.cjs']);
|
|
453
564
|
|
|
454
565
|
/**
|
|
455
566
|
* Configuration files (.env, bundle files) modified AFTER the worker `pid`
|
|
@@ -1077,6 +1188,8 @@ function writeNodeClasses(io, { workerDir, manifests, log = null, version = null
|
|
|
1077
1188
|
|
|
1078
1189
|
module.exports = {
|
|
1079
1190
|
installWorkerBundle,
|
|
1191
|
+
listBundleFiles,
|
|
1192
|
+
missingLocalRequires,
|
|
1080
1193
|
ensureWorkerDependencies,
|
|
1081
1194
|
declaredDependencies,
|
|
1082
1195
|
readPkgVersion,
|