@animastor/installer 0.2.12 → 0.2.14

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 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.12, Node >=20, zero runtime deps
17
+ ├── package.json @animastor/installer 0.2.14, 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)
@@ -213,6 +213,15 @@ recomputed on every run because the platform's port and notebook prefix change
213
213
  between boots. Answers already given (a declined optional workflow, a declined
214
214
  model download) are remembered and not asked again, also under `--yes`.
215
215
 
216
+ Model check and download log (0.2.14): besides the standard ComfyUI folders the
217
+ check scans the top folder (`models/<folder>`) of every `target_dir` in the
218
+ loaded manifests, plus `extra_model_paths.yaml` — a file the installer
219
+ downloads is always visible to the check. Present files up to 1 GiB that match
220
+ the manifest size are compared by sha256, larger ones by size. Every model file
221
+ is logged with name, size and outcome (`downloaded`, `present, verified sha256
222
+ — skipped`, `failed: <reason>`). `install`, `doctor` and `resume` append their
223
+ log to `~/animastor/logs/bootstrap.log`, not only `animastor boot`.
224
+
216
225
  ## Manifest resolution (MANIFEST_ROOT contract)
217
226
 
218
227
  1. `/app/artifacts/install-manifests` (baked container layout)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@animastor/installer",
3
- "version": "0.2.12",
3
+ "version": "0.2.14",
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": {
@@ -54,7 +54,7 @@ const { buildInstallPlan, renderPlanText, planNeedsPythonRuntime } = require('./
54
54
  const manifest = require('./install-manifest');
55
55
  const uninstaller = require('./uninstaller');
56
56
  const { createPrompt, NoTerminalError } = require('./engine/tty');
57
- const { renderBanner, renderFinalSummary } = require('./engine/summary');
57
+ const { renderBanner, renderFinalSummary, foreignRestartNote } = require('./engine/summary');
58
58
  const fixes = require('./engine/fixes');
59
59
  const workerMod = require('./engine/worker');
60
60
  const comfyuiMod = require('./engine/comfyui');
@@ -440,6 +440,20 @@ function priorReusableDecisions(state) {
440
440
  return out;
441
441
  }
442
442
 
443
+ /**
444
+ * Recorded answers that apply to THIS run (0.2.13). A recorded "no" to REQUIRED
445
+ * files (models, custom nodes) is kept only by `doctor --yes` / boot — the
446
+ * unattended path never downloads behind the user's back. Everywhere else it
447
+ * is forgotten: the question is asked again (`install --yes` answers yes).
448
+ * Before, one "no" made every later run list "Download model …" and skip it.
449
+ */
450
+ function applicableDecisions(state, { doctor = false, yes = false } = {}) {
451
+ const out = priorReusableDecisions(state);
452
+ if (doctor && yes) return out;
453
+ for (const k of ['install_models', 'install_custom_nodes']) if (out[k] === false || out[k] === 'no') delete out[k];
454
+ return out;
455
+ }
456
+
443
457
  /**
444
458
  * The boot script (`animastor doctor --yes`, no TTY): one line of output and
445
459
  * an exit code, nothing else. `ANIMASTOR_BOOT=1` forces it on a TTY too.
@@ -696,7 +710,10 @@ async function platformNodeDepsGate(io, {
696
710
  dropSnap();
697
711
  out.failed = true;
698
712
  out.reason = inst.failed.map((f) => `${f.directory}: ${f.reason}`).join('; ');
699
- out.fix = `fix the pip error above (network, disk space, a package conflict), then run: ${tool} doctor --yes --restart-platform-comfy`;
713
+ const build = prereq.buildToolsRemediation(io, { output: inst.failed.map((f) => f.output).join('\n'), python: py.python });
714
+ out.fix = build
715
+ ? `${build.summary}: ${build.command} && ${tool} doctor --yes --restart-platform-comfy`
716
+ : `fix the pip error above (network, disk space, a package conflict), then run: ${tool} doctor --yes --restart-platform-comfy`;
700
717
  return out;
701
718
  }
702
719
  const again = nodeDeps.checkNodeDeps(io, { python: py.python, root, manifests, extraPaths: extraPaths() });
@@ -866,7 +883,7 @@ function nodeDepsFailedResult({ gate, mode }) {
866
883
  warnings: [],
867
884
  blocked: [],
868
885
  verification: null,
869
- results: { comfy_owner: { owner: gate.instance && gate.instance.owner, mode, url: (gate.instance && gate.instance.url) || null }, worker: [] },
886
+ results: { comfy_owner: { owner: gate.instance && gate.instance.owner, mode, pid: (gate.instance && gate.instance.pid) || null, url: (gate.instance && gate.instance.url) || null }, worker: [] },
870
887
  e2e: [
871
888
  { id: 'node-deps', ok: false, label: 'Custom-node dependencies', detail: gate.reason, fix: gate.fix || null },
872
889
  { id: 'worker', ok: null, label: 'Worker → ComfyUI', detail: 'not started — the ComfyUI has no node classes for this profile', fix: null },
@@ -928,6 +945,30 @@ function bootLogPath(flags) {
928
945
  return flags['boot-log'] || path.join(path.dirname(resolveWorkerDir(flags)), 'logs', 'bootstrap.log');
929
946
  }
930
947
 
948
+ /**
949
+ * Copy the log of an install/doctor/resume run to bootstrap.log (0.2.14) —
950
+ * before, only `animastor boot` wrote there and an interactive install left no
951
+ * trace. Not when stdout already IS that file (the boot run). Called after the
952
+ * ownership gates, so nothing is created as the wrong user. Never fatal.
953
+ */
954
+ function teeToBootLog(logger, { io, flags, command, stdoutFd = 1 }) {
955
+ const logFile = bootLogPath(flags);
956
+ try {
957
+ const out = fs.fstatSync(stdoutFd);
958
+ const log = fs.statSync(logFile);
959
+ if (out.ino === log.ino && out.dev === log.dev) return false;
960
+ } catch (_) { /* no log file yet */ }
961
+ try {
962
+ io.fs.mkdirSync(path.dirname(logFile), { recursive: true });
963
+ io.fs.appendFileSync(logFile, `\n===== animastor ${command} ${new Date(io.now()).toISOString()} (installer ${ownVersion()}) =====\n`);
964
+ } catch (err) {
965
+ logger.warn(`${logFile} is not writable: ${err.message}`);
966
+ return false;
967
+ }
968
+ logger.teeTo((line) => { try { io.fs.appendFileSync(logFile, `${line}\n`); } catch (_) { /* the run goes on */ } });
969
+ return true;
970
+ }
971
+
931
972
  /** System boot time from /proc/stat (btime) as ISO, or null. */
932
973
  function systemBootTime(io) {
933
974
  try {
@@ -1145,9 +1186,8 @@ async function cmdPlan(flags) {
1145
1186
  const repoRoot = resolveRepoRoot(flags);
1146
1187
  const io = createRealIo();
1147
1188
  const crypto = require('crypto');
1148
- const env = probeEnvironment(io, { root, workerDir, crypto, workerType: null });
1149
-
1150
1189
  const loadedManifests = flags.profiles.map((p) => manifest.loadManifest(p));
1190
+ const env = await probeMod.hashProbedModels(io, probeEnvironment(io, { root, workerDir, crypto, workerType: null, manifests: loadedManifests }), loadedManifests);
1151
1191
  const mode = flags.mode || (env.comfyui && env.comfyui.present ? 'existing' : 'managed');
1152
1192
  const { plan } = resolveAndPlan({ manifests: loadedManifests, env, mode, decisions: {} });
1153
1193
  console.log(plan.plan_text);
@@ -1340,7 +1380,9 @@ async function cmdInstall(flags, { doctor = false } = {}) {
1340
1380
  const env = probeEnvironment(realIo, {
1341
1381
  root, workerDir, crypto,
1342
1382
  workerType: loadedManifests.length === 1 ? (loadedManifests[0].worker_bundle || {}).worker_type : null,
1383
+ manifests: loadedManifests,
1343
1384
  });
1385
+ await probeMod.hashProbedModels(realIo, env, loadedManifests);
1344
1386
 
1345
1387
  // The dry-run guard wraps everything handed to the engine so any
1346
1388
  // accidental mutation throws "dry-run violation" instead of executing.
@@ -1351,7 +1393,7 @@ async function cmdInstall(flags, { doctor = false } = {}) {
1351
1393
  // its models already in place needs none). Previously answered steps
1352
1394
  // (a declined optional workflow, a declined model download) are not
1353
1395
  // asked again.
1354
- const priorDecisions = priorReusableDecisions(priorState);
1396
+ const priorDecisions = applicableDecisions(priorState, { doctor, yes });
1355
1397
  const { plan, report: planReport } = await resolveAndPlanWithSizes({ io: realIo, manifests: loadedManifests, env, mode, decisions: priorDecisions });
1356
1398
 
1357
1399
  // Prerequisites & ownership BEFORE any prompt/change: a missing
@@ -1469,10 +1511,9 @@ async function cmdInstall(flags, { doctor = false } = {}) {
1469
1511
  const secrets = {};
1470
1512
 
1471
1513
  if (yes) {
1472
- // --yes answers everything EXCEPT steps the user already declined:
1473
- // a "no" to the optional workflows (and to model/node downloads)
1474
- // is remembered, so a boot-time `doctor --yes` never installs them
1475
- // behind the user's back.
1514
+ // --yes answers everything EXCEPT what is still declined for this run
1515
+ // (see applicableDecisions): optional workflows always, model/node
1516
+ // downloads only for the unattended `doctor --yes`.
1476
1517
  const yd = yesDecisions();
1477
1518
  for (const k of ['workflows', 'install_models', 'install_custom_nodes']) {
1478
1519
  if (priorDecisions[k] !== undefined) yd[k] = priorDecisions[k];
@@ -1559,6 +1600,7 @@ async function cmdInstall(flags, { doctor = false } = {}) {
1559
1600
  return;
1560
1601
  }
1561
1602
 
1603
+ teeToBootLog(logger, { io: realIo, flags, command: doctor ? 'doctor' : 'install' });
1562
1604
  const result = await runInstallation({
1563
1605
  manifests: loadedManifests, mode, io,
1564
1606
  roots: { comfyuiRoot: root, workerDir, statePath, repoRoot, hubUrl, toolsDir: resolveToolsDir(flags) },
@@ -1570,6 +1612,19 @@ async function cmdInstall(flags, { doctor = false } = {}) {
1570
1612
  hubUrlExplicit: !!flags['hub-url'],
1571
1613
  nodeBinary: nodePick,
1572
1614
  replaceWorkerKey,
1615
+ // 0.2.13: only an interactive run may ask for a new Worker Key
1616
+ askWorkerKey: prompt.available && !yes && !boot
1617
+ ? () => prompt.secret('The Worker Key is revoked or wrong. Paste a new Worker Key from Animastor → Settings → Workers (hidden input, Enter = skip)')
1618
+ : null,
1619
+ // 0.2.13: the node-deps gate again, for nodes installed by this run
1620
+ platformNodeDeps: async (current) => {
1621
+ const g = await platformNodeDepsGate(realIo, {
1622
+ instance: current, state: stateStore.loadState(realIo, statePath), root, manifests: loadedManifests, flags, boot, yes, prompt,
1623
+ waitMs: Math.max(180000, comfyWaitMs), logger, statePath, workerDir,
1624
+ otherManifests: otherProfileManifests(priorState, flags.profiles, { logger }), command: doctor ? 'doctor' : 'install',
1625
+ });
1626
+ return { ...g, ownedServices: nodeDepsOwnedServices(g) };
1627
+ },
1573
1628
  comfyOwner: instance,
1574
1629
  comfyWaitMs,
1575
1630
  nodeClassesDeadline,
@@ -1581,7 +1636,7 @@ async function cmdInstall(flags, { doctor = false } = {}) {
1581
1636
  hubVersion,
1582
1637
  },
1583
1638
  });
1584
- printResult(withPre({ ...result, node_deps_overrides: depsGate ? depsGate.overrides : [] }), { flags, mode, boot, hubVersion });
1639
+ printResult(withPre({ ...result, node_deps_overrides: result.results.node_deps_overrides || (depsGate ? depsGate.overrides : []) }), { flags, mode, boot, hubVersion });
1585
1640
  } catch (err) {
1586
1641
  if (err instanceof NoTerminalError) {
1587
1642
  console.error('');
@@ -1674,6 +1729,7 @@ async function cmdResume(flags) {
1674
1729
  const env = probeEnvironment(io, {
1675
1730
  root, workerDir, crypto,
1676
1731
  workerType: loadedManifests.length === 1 ? (loadedManifests[0].worker_bundle || {}).worker_type : null,
1732
+ manifests: loadedManifests,
1677
1733
  });
1678
1734
 
1679
1735
  // restored non-secret decisions from state; CLI --yes can still widen them.
@@ -1688,6 +1744,7 @@ async function cmdResume(flags) {
1688
1744
  flags, prompt: null, prior: priorToolsDecision(io, statePath),
1689
1745
  });
1690
1746
 
1747
+ teeToBootLog(logger, { io, flags, command: 'resume' });
1691
1748
  const result = await runInstallation({
1692
1749
  manifests: loadedManifests, mode, io,
1693
1750
  roots: { comfyuiRoot: root, workerDir, statePath, repoRoot, hubUrl, toolsDir: resolveToolsDir(flags) },
@@ -1828,7 +1885,9 @@ async function cmdVerify(flags) {
1828
1885
  ? flags.profiles.map((p) => manifest.loadManifest(p))
1829
1886
  : [manifest.loadManifest('image/qwen-image')]; // default
1830
1887
 
1831
- const env = probeEnvironment(io, { root, workerDir, crypto, workerType: loadedManifests[0].worker_bundle.worker_type });
1888
+ const env = await probeMod.hashProbedModels(io, probeEnvironment(io, {
1889
+ root, workerDir, crypto, workerType: loadedManifests[0].worker_bundle.worker_type, manifests: loadedManifests,
1890
+ }), loadedManifests);
1832
1891
  const report = resolver.resolveInstallation({ manifests: loadedManifests, environment: env, mode: 'existing' });
1833
1892
  const { buildVerificationReport } = require('./verification-report');
1834
1893
  const ver = buildVerificationReport({ report, live: {} });
@@ -1884,7 +1943,11 @@ function printOneLineSummary(result, { flags = {}, mode = null } = {}) {
1884
1943
  const head = summary.ok ? 'OK' : `FAILED — ${summary.failures.length} problem(s)`;
1885
1944
  console.log(`animastor doctor: ${head} — ${what} (${tool})`);
1886
1945
  if (!summary.ok) {
1887
- for (const f of summary.failures) console.log(` ✗ ${f.label}: ${f.detail || ''}${f.fix ? ` — fix: ${f.fix}` : ''}`);
1946
+ for (const f of summary.failures) {
1947
+ console.log(` ✗ ${f.label}: ${f.detail || ''}${f.fix ? ` — fix: ${f.fix}` : ''}`);
1948
+ const note = foreignRestartNote(f.fix, owner && owner.pid);
1949
+ if (note) console.log(` ${note}`);
1950
+ }
1888
1951
  process.exitCode = 1;
1889
1952
  }
1890
1953
  }
@@ -1913,7 +1976,7 @@ function printResult(result, { flags = {}, mode = null, boot = false } = {}) {
1913
1976
  }
1914
1977
  const tool = (result.results && result.results.management_tools && result.results.management_tools.command) || toolCommand(flags);
1915
1978
  const extra = resultExtras(result, tool);
1916
- const summary = renderFinalSummary({ verification: result.verification, e2e: result.e2e || [], extra, tool, mode: mode || result.mode });
1979
+ const summary = renderFinalSummary({ verification: result.verification, e2e: result.e2e || [], extra, tool, mode: mode || result.mode, comfyPid: ((result.results && result.results.comfy_owner) || {}).pid || null });
1917
1980
  console.log(summary.text);
1918
1981
  console.log(`current job: ${currentJobOf(result, flags)}`);
1919
1982
  // The full path is printed even when ~/.local/bin is already in PATH:
@@ -2336,7 +2399,7 @@ async function main() {
2336
2399
  console.error(' management (the `animastor` command in PATH):');
2337
2400
  console.error(' animastor start | stop | status | logs [-f] | doctor [--new-key] [--wait-job-ms N] [--force] | boot');
2338
2401
  console.error(' boot: node startup script — detaches `doctor --yes` (log ~/animastor/logs/bootstrap.log), exits 0');
2339
- console.error(' --restart-platform-comfy / --no-restart-platform-comfy restart the platform ComfyUI after node deps');
2402
+ console.error(' --restart-platform-comfy / --no-restart-platform-comfy restart the platform ComfyUI after node deps (a process started outside the installer: its jobs are lost)');
2340
2403
  console.error(' --accept-node-deps-overrides consent: the node-deps overlay may replace a package another profile / ComfyUI core uses');
2341
2404
  console.error(' (also: monitor | reboot-worker | reboot-comfyui)');
2342
2405
  console.error(' (--state/--root/--worker-dir/--port override discovery)');
@@ -2361,10 +2424,10 @@ module.exports = {
2361
2424
  cmdUninstall, cmdStatus, cmdMonitor, cmdRebootWorker, cmdRebootComfyUI, resolveAndPlan,
2362
2425
  makeSecretProvider, resolveToolsDecision, resolveToolsDir, installOptions, runHostGates,
2363
2426
  PLATFORM_RUNTIME, printPlatformNotices, homeDir,
2364
- toolCommand, toolCommandPath, detectHubVersion, priorReusableDecisions, isBootRun,
2427
+ toolCommand, toolCommandPath, detectHubVersion, priorReusableDecisions, applicableDecisions, isBootRun,
2365
2428
  missingRequiredHostPackages, shouldWaitForPlatformComfy, platformComfyGate, platformComfyMissingResult,
2366
2429
  restartPlatformComfyDecision, platformNodeDepsGate, nodeDepsFailedResult, recordInstallerOption,
2367
- cmdBoot, bootChildArgs, bootLogPath, startupScriptLine,
2430
+ cmdBoot, bootChildArgs, bootLogPath, teeToBootLog, startupScriptLine,
2368
2431
  preflightSelfUpdate, preflightExtras, installedToolsVersion, ownVersion,
2369
2432
  nodeDepsOwnedServices, recordOwnedServices, otherProfileManifests, overridesStep,
2370
2433
  };
@@ -168,6 +168,28 @@ async function downloadArtifact(io, spec, opts = {}) {
168
168
  };
169
169
  }
170
170
 
171
+ /** What a verification grade proved, in log words. */
172
+ const GRADE_TEXT = {
173
+ 'checksum-verified': 'verified sha256',
174
+ 'checksum-prefix-verified': 'verified sha256 prefix',
175
+ 'size-verified': 'verified size',
176
+ 'files-verified': 'verified file list',
177
+ };
178
+
179
+ /**
180
+ * One log line per model file (0.2.14): name, size, outcome —
181
+ * model models/x/a.bin (123 bytes): downloaded, verified sha256
182
+ * model models/x/a.bin (123 bytes): present, verified sha256 — skipped
183
+ * model models/x/a.bin: failed: HTTP 404 from source
184
+ */
185
+ function modelFileLine({ file, size = null, status, grade = null, reason = null }) {
186
+ const name = `model ${file}${typeof size === 'number' ? ` (${size} bytes)` : ''}`;
187
+ const proof = GRADE_TEXT[grade] || 'not verified (no checksum or size in the manifest)';
188
+ if (status === 'downloaded' || status === 'resumed') return `${name}: downloaded${status === 'resumed' ? ' (resumed)' : ''}, ${proof}`;
189
+ if (status === 'skipped') return `${name}: present, ${proof} — skipped`;
190
+ return `${name}: ${status || 'failed'}: ${reason || grade || 'unknown reason'}`;
191
+ }
192
+
171
193
  // ---------------------------------------------------------------------------
172
194
  // Platform adapters — manifest source → request headers
173
195
  // ---------------------------------------------------------------------------
@@ -531,6 +553,7 @@ module.exports = {
531
553
  SIZE_TOLERANCE,
532
554
  verifyFile,
533
555
  downloadArtifact,
556
+ modelFileLine,
534
557
  makeHeaderProvider,
535
558
  modelscopeStrategy,
536
559
  listModelScopeFiles,
@@ -40,6 +40,7 @@ const management = require('../management');
40
40
  const comfyOwnerMod = require('./comfy-owner');
41
41
  const nodeDeps = require('./node-deps');
42
42
  const pydeps = require('./pydeps');
43
+ const hubPreflight = require('./hub-preflight');
43
44
  const { createProgressReporter } = require('./progress');
44
45
  const { buildVerificationReport } = require('../verification-report');
45
46
 
@@ -272,8 +273,10 @@ async function runInstallation(args) {
272
273
  : probe.probeEnvironment(io, {
273
274
  root: comfyuiRoot, workerDir, crypto,
274
275
  workerType: manifests.length === 1 ? (manifests[0].worker_bundle || {}).worker_type : null,
276
+ manifests,
275
277
  })
276
278
  );
279
+ if (!dryRun) await probe.hashProbedModels(io, env, manifests);
277
280
  const device = env.device || (env.gpu ? 'cuda' : 'cpu');
278
281
  if (device === 'cpu') {
279
282
  result.warnings.push(CPU_MODE_WARNING);
@@ -331,8 +334,8 @@ async function runInstallation(args) {
331
334
  // when they do not contradict the machine: an install-state that says
332
335
  // "managed / startComfyui=true" while the PLATFORM runs its own ComfyUI
333
336
  // must never make the installer start a second one on 8188.
334
- const comfyOwner = options.comfyOwner || null;
335
- const foreignComfy = comfyOwner && comfyOwner.owner === 'foreign' ? comfyOwner : null;
337
+ let comfyOwner = options.comfyOwner || null;
338
+ let foreignComfy = comfyOwner && comfyOwner.owner === 'foreign' ? comfyOwner : null;
336
339
  if (!dryRun && comfyOwner) {
337
340
  for (const c of comfyOwner.conflicts || []) log.info(`install state corrected — ${c.message}`);
338
341
  if (st.mode !== mode) {
@@ -489,6 +492,24 @@ async function runInstallation(args) {
489
492
  try {
490
493
  save();
491
494
 
495
+ // 4.0a Worker Key preflight (0.2.13) — a revoked key kept in .env is
496
+ // found and replaced HERE, before hours of downloads, not at `start
497
+ // worker`. Without a terminal nothing is asked: the installation goes
498
+ // on, the worker is not started and the result names the fix.
499
+ const workerWanted = decisions.worker_setup === true || decisions.worker_setup === 'yes'
500
+ || !!(stepById(plan, 'worker-key') && (stepById(plan, 'worker-key').provided || decisions.worker_key_provided === true));
501
+ const hubTargets = hubPreflight.workerHubTargets(io, { workerDir, hubUrl, hubUrlExplicit: !!options.hubUrlExplicit });
502
+ let keyCheck = { status: 'skipped', reason: null, token: null, replaced: false };
503
+ if (workerWanted && workerDir) {
504
+ const typed = secretProvider && (options.replaceWorkerKey || !hubTargets.token) ? await secretProvider(hubPreflight.TOKEN_KEY) : null;
505
+ const token = typed || hubTargets.token;
506
+ if (token && log.registerSecret) log.registerSecret(token);
507
+ keyCheck = await hubPreflight.ensureWorkerKey(io, {
508
+ apiUrl: hubTargets.apiUrl, token, workerVersion: worker.readPkgVersion(io, workerDir),
509
+ ask: options.askWorkerKey || null, log,
510
+ });
511
+ }
512
+
492
513
  // 4.1 ComfyUI -----------------------------------------------------------
493
514
  const comfyStep = stepById(plan, 'comfyui-update');
494
515
  if (comfyStep && comfyStep.abort) {
@@ -681,22 +702,10 @@ async function runInstallation(args) {
681
702
  const nodesApproved = !runtimeFatal && nodesStep && nodesStep.action && nodesStep.decision === 'yes';
682
703
  if (!runtimeFatal && (nodesApproved || retryDeps.length > 0)) {
683
704
  const python = platformAdapter.venvPythonBin(path.join(comfyuiRoot, 'venv'));
684
- // Check for C build tools (gcc, python3-dev, libsndfile1-dev) that
685
- // packages like funasr/soundfile need. Missing tools produce opaque
686
- // metadata-generation-failed errors from pip — catch early and give
687
- // a precise remediation command. (Which tools/packages to check is
688
- // a platform concern — the adapter answers it.)
689
- const buildCheck = platformAdapter.checkBuildPrerequisites(io, {
690
- python: io.fs.existsSync(python) ? python : 'python3', log,
691
- });
692
- if (!buildCheck.ok) {
693
- result.remediation = {
694
- code: 'MISSING_BUILD_TOOLS',
695
- summary: buildCheck.message,
696
- package: buildCheck.remediation.package,
697
- command: buildCheck.remediation.command,
698
- };
699
- }
705
+ // A platform ComfyUI imports with ITS interpreter: pip into
706
+ // <root>/venv is useful only when that is the same Python (0.2.13).
707
+ const processPython = foreignComfy ? nodeDeps.pythonOfProcess(io, foreignComfy.pid).python : null;
708
+ const nodesPython = io.fs.existsSync(python) && (!foreignComfy || processPython === python) ? python : null;
700
709
  const approvedIds = ((nodesStep && nodesStep.missing) || []).map((x) => x.id);
701
710
  const repairOnlyIds = retryDeps.filter((id) => !approvedIds.includes(id));
702
711
  const effectiveStep = nodesApproved
@@ -709,12 +718,17 @@ async function runInstallation(args) {
709
718
  const nodeTorchSpec = pickTorchSpec(manifests, decisions, result.warnings, device);
710
719
  const r = await log.step('install custom nodes', () => withBusySync('Installing custom nodes', () => nodes.installCustomNodes(io, {
711
720
  root: comfyuiRoot, manifests, planStep: effectiveStep,
712
- python: io.fs.existsSync(python) ? python : null,
721
+ python: nodesPython,
713
722
  torchSpec: nodeTorchSpec ? nodeTorchSpec.spec : null,
714
723
  retryDeps, log,
715
724
  })));
716
725
  result.results.custom_nodes = r.ok ? r.value : [{ status: 'failed', reason: String(r.error && r.error.message) }];
717
726
  for (const item of result.results.custom_nodes) {
727
+ // Host build packages are asked for only when a source build failed.
728
+ if (item.pip_output && !result.remediation) {
729
+ result.remediation = prereq.buildToolsRemediation(io, { output: item.pip_output, python: nodesPython || 'python3', platformAdapter });
730
+ }
731
+ delete item.pip_output;
718
732
  // Only directories the installer actually created are ours.
719
733
  if (item.status === 'installed' && item.origin === 'installed' && item.directory) {
720
734
  state.addOwnedComponent(st, 'custom_nodes', { id: item.id, path: path.join(comfyuiRoot, 'custom_nodes', item.directory) });
@@ -754,8 +768,41 @@ async function runInstallation(args) {
754
768
  }
755
769
  }
756
770
 
771
+ // 4.3a A node installed just now brought its requirements.txt with it:
772
+ // the dependency gate of the platform's ComfyUI ran BEFORE the clone and
773
+ // could not see it, so it runs again (overlay install + restart, 0.2.13).
774
+ let nodeDepsGate = null;
775
+ const freshNodes = (result.results.custom_nodes || []).filter((x) => x.status === 'installed' && x.origin === 'installed');
776
+ if (!runtimeFatal && foreignComfy && freshNodes.length > 0 && options.platformNodeDeps) {
777
+ log.info(`checking the Python dependencies of the installed node(s): ${freshNodes.map((x) => x.directory).join(', ')}`);
778
+ nodeDepsGate = await options.platformNodeDeps(comfyOwner);
779
+ Object.assign(st.installer_options, nodeDepsGate.record);
780
+ for (const e of nodeDepsGate.ownedServices || []) state.addOwnedComponent(st, 'services', e);
781
+ result.results.node_deps_overrides = nodeDepsGate.overrides;
782
+ if (nodeDepsGate.instance && nodeDepsGate.instance.owner === 'foreign') {
783
+ comfyOwner = nodeDepsGate.instance;
784
+ foreignComfy = comfyOwner;
785
+ options.comfyOwner = comfyOwner;
786
+ if (st.comfy_owner) Object.assign(st.comfy_owner, { pid: comfyOwner.pid ?? null, url: comfyOwner.url || null });
787
+ if (foreignComfy.port) options.comfyPort = foreignComfy.port;
788
+ }
789
+ if (nodeDepsGate.failed) {
790
+ options.nodeClassesDeadline = null; // the cause is known: waiting cannot help
791
+ log.error(`custom-node dependencies: ${nodeDepsGate.reason}`);
792
+ }
793
+ save();
794
+ }
795
+
757
796
  // 4.4 Models ---------------------------------------------------------------
758
797
  const modelsStep = stepById(plan, 'models');
798
+ // Never silent (0.2.13): the plan lists these files as missing.
799
+ if (!runtimeFatal && modelsStep && modelsStep.skipped_by_user) {
800
+ log.warn(`model downloads skipped — declined (${modelsStep.missing.length} missing: ${modelsStep.missing.map((x) => x.label).join(', ')})`);
801
+ }
802
+ // Every model file is logged with its outcome (0.2.14) — also the ones
803
+ // the plan found in place, so the plan, this log and the final check
804
+ // speak about the same files.
805
+ logPresentModels(io, { env, report, manifests, log });
759
806
  if (!runtimeFatal && modelsStep && modelsStep.action && modelsStep.decision === 'yes') {
760
807
  const getHeader = downloader.makeHeaderProvider(process.env);
761
808
  const missingIds = (modelsStep.missing || []).map((x) => x.id);
@@ -782,6 +829,7 @@ async function runInstallation(args) {
782
829
  const strategy = downloader.modelscopeStrategy(dep);
783
830
  if (strategy.mechanism === 'node_auto_download') {
784
831
  result.results.models.push({ id: spec.id, status: 'deferred-to-node', reason: strategy.note });
832
+ logModelResult(io, { log, res: { status: 'deferred-to-node', reason: strategy.note }, target: spec.target_path, absTarget });
785
833
  state.setArtifact(st, spec.id, 'missing', { note: strategy.note });
786
834
  } else if (strategy.mechanism === 'installer_preload') {
787
835
  // D2 closed: installer pre-downloads ModelScope repos
@@ -812,6 +860,9 @@ async function runInstallation(args) {
812
860
  const res = r.ok ? r.value : { status: 'failed', reason: String(r.error && r.error.message) };
813
861
  const status = res.status === 'failed' ? 'failed' : res.status === 'skipped' ? 'verified' : 'installed';
814
862
  result.results.models.push({ id: spec.id, ...res });
863
+ logModelResult(io, {
864
+ log, res, target: spec.target_path, absTarget: path.join(loc ? loc.base : comfyuiRoot, dlSpec.target_path),
865
+ });
815
866
  if (status === 'installed') {
816
867
  state.addOwnedComponent(st, 'models', {
817
868
  id: spec.id,
@@ -825,6 +876,7 @@ async function runInstallation(args) {
825
876
  continue; // skip the generic downloadArtifact below
826
877
  } else {
827
878
  result.results.models.push({ id: spec.id, status: 'blocked', reason: strategy.note });
879
+ logModelResult(io, { log, res: { status: 'blocked', reason: strategy.note }, target: spec.target_path, absTarget });
828
880
  state.setArtifact(st, spec.id, 'missing', { note: strategy.note });
829
881
  }
830
882
  if (strategy.mechanism !== 'installer_preload') continue;
@@ -842,6 +894,7 @@ async function runInstallation(args) {
842
894
  if (progress && progress.endFile) progress.endFile({ status: r.ok ? r.value.status : 'failed' });
843
895
  const res = r.ok ? r.value : { status: 'failed', reason: String(r.error && r.error.message) };
844
896
  result.results.models.push({ id: spec.id, ...res });
897
+ logModelResult(io, { log, res, target: spec.target_path, absTarget });
845
898
  if (res.status === 'downloaded' || res.status === 'resumed') {
846
899
  state.addOwnedComponent(st, 'models', {
847
900
  id: spec.id,
@@ -1032,8 +1085,6 @@ async function runInstallation(args) {
1032
1085
  // reach .env on every run: otherwise an already-running worker keeps
1033
1086
  // its stale wiring forever.
1034
1087
  const keyStep = stepById(plan, 'worker-key');
1035
- const workerWanted = decisions.worker_setup === true || decisions.worker_setup === 'yes'
1036
- || (keyStep && (keyStep.provided || decisions.worker_key_provided === true));
1037
1088
  let tokenValue = null; // held in memory only; never stored on result/state
1038
1089
  let workerConfigChanged = false; // .env or bundle changed in THIS run → restart a running worker
1039
1090
  if (workerWanted) {
@@ -1072,6 +1123,15 @@ async function runInstallation(args) {
1072
1123
  tokenValue = fresh;
1073
1124
  }
1074
1125
  }
1126
+ if (keyCheck.status === 'rejected') {
1127
+ // a key Animastor refuses is never written (the next run asks again)
1128
+ delete values[hubPreflight.TOKEN_KEY];
1129
+ delete secretOverrides[hubPreflight.TOKEN_KEY];
1130
+ tokenValue = keyCheck.token; // memory only: the verification reports the failed registration
1131
+ } else if (keyCheck.replaced) {
1132
+ secretOverrides[hubPreflight.TOKEN_KEY] = keyCheck.token;
1133
+ tokenValue = keyCheck.token;
1134
+ }
1075
1135
  const cfg = await log.step('configure worker .env', async () => worker.configureEnv(io, {
1076
1136
  workerDir, manifest, values,
1077
1137
  overrides: decisions.apply_fixes !== false ? desired : {},
@@ -1170,7 +1230,17 @@ async function runInstallation(args) {
1170
1230
  let startedWorkerPid = null;
1171
1231
  let workerReady = null;
1172
1232
  let workerStart = null;
1173
- if (options.startWorker && workerDir && !runtimeFatal) {
1233
+ let hubProtocol = null;
1234
+ if (options.startWorker && workerDir && !runtimeFatal && keyCheck.status !== 'rejected') {
1235
+ hubProtocol = await hubPreflight.checkHubProtocol(io, {
1236
+ hubUrl: hubPreflight.workerHubTargets(io, { workerDir, hubUrl }).hubUrl, workerDir,
1237
+ });
1238
+ if (hubProtocol.status === 'ok') log.info(`hub protocol: compatible (worker ${hubProtocol.worker.join(', ')}, hub ${hubProtocol.hub.join(', ')})`);
1239
+ else if (hubProtocol.reason) log.warn(hubProtocol.reason);
1240
+ }
1241
+ const startBlocked = keyCheck.status === 'rejected' || !!(hubProtocol && hubProtocol.status === 'mismatch') || !!(nodeDepsGate && nodeDepsGate.failed);
1242
+ if (startBlocked && options.startWorker && workerDir && !runtimeFatal) log.warn('worker not started — see the result for the cause');
1243
+ if (options.startWorker && workerDir && !runtimeFatal && !startBlocked) {
1174
1244
  const r = await log.step('start worker', async () => {
1175
1245
  const bundleChanged = !!options.bundleRefreshedEarly || result.results.worker.some((x) => x.bundle && (x.bundle.files_installed || []).length > 0);
1176
1246
  // Installer 0.2.8: a running worker is restarted only when its
@@ -1290,7 +1360,7 @@ async function runInstallation(args) {
1290
1360
  comfyTried: (result.results.comfy_url && result.results.comfy_url.tried) || (foreignComfy && foreignComfy.url ? [foreignComfy.url] : []),
1291
1361
  platformComfy: !!foreignComfy,
1292
1362
  workerWanted: !!(options.startWorker && workerDir && !runtimeFatal),
1293
- workerStart, workerReady,
1363
+ workerStart, workerReady, keyCheck, hubProtocol, nodeDepsGate,
1294
1364
  tool: options.toolCommand || toolCommandFrom(result.results.management_tools),
1295
1365
  });
1296
1366
 
@@ -1380,6 +1450,41 @@ function pickUpdateTarget(manifest) {
1380
1450
  throw new Error('no update target in manifest');
1381
1451
  }
1382
1452
 
1453
+ /** Log the outcome of one download: a single file, or every file of a repo. */
1454
+ function logModelResult(io, { log, res, target, absTarget }) {
1455
+ const files = res.files && res.files.length > 0 ? res.files : [{ ...res, path: null }];
1456
+ for (const f of files) {
1457
+ let size = null;
1458
+ try {
1459
+ const st = io.fs.statSync(f.path ? path.join(absTarget, f.path) : absTarget);
1460
+ if (st.isFile) size = st.size;
1461
+ } catch (_) { /* not on disk */ }
1462
+ const line = downloader.modelFileLine({ ...f, file: f.path ? `${target}/${f.path}` : target, size });
1463
+ if (f.status === 'failed' || f.status === 'blocked') log.error(line);
1464
+ else log.info(line);
1465
+ }
1466
+ }
1467
+
1468
+ /** Log the model files the resolver found on disk (they are not downloaded). */
1469
+ function logPresentModels(io, { env, report, manifests, log }) {
1470
+ const sizes = new Map((env.models || []).map((m) => [m.path, m.size_bytes]));
1471
+ for (const e of report.entries) {
1472
+ const dep = findModelDep(manifests, e.id);
1473
+ if (!dep || !e.found || (e.kind !== 'model' && e.kind !== 'model_repo')) continue;
1474
+ const dir = path.posix.normalize(String(dep.target_dir));
1475
+ // a repo lists its files with the full path or relative to its folder
1476
+ const files = e.found.path ? [e.found.path] : (e.found.files || []).map((f) => (sizes.has(f) ? f : `${dir}/${f}`));
1477
+ for (const file of files.filter((f) => !f.endsWith('.part'))) {
1478
+ const size = sizes.get(file);
1479
+ if (e.status === 'incompatible') {
1480
+ log.warn(`${downloader.modelFileLine({ file, size, status: 'left as is', reason: e.reason })} — to download it again, delete the file and repeat the run`);
1481
+ } else {
1482
+ log.info(downloader.modelFileLine({ file, size, status: 'skipped', grade: e.grade }));
1483
+ }
1484
+ }
1485
+ }
1486
+ }
1487
+
1383
1488
  function findModelDep(manifests, id) {
1384
1489
  for (const m of manifests) {
1385
1490
  const dep = (m.dependencies || []).find((d) => d.id === id);
@@ -1435,7 +1540,7 @@ function toolCommandFrom(tools) {
1435
1540
  * prints exactly these (no "scroll up").
1436
1541
  * @returns {Promise<Array<{ id, ok: boolean|null, label, detail, fix }>>}
1437
1542
  */
1438
- async function endToEndChecks(io, { mode, comfyUrl, comfyPort, hubUrl, workerWanted, workerStart, workerReady, tool = 'animastor', comfyTried = [], platformComfy = false }) {
1543
+ async function endToEndChecks(io, { mode, comfyUrl, comfyPort, hubUrl, workerWanted, workerStart, workerReady, keyCheck = null, hubProtocol = null, nodeDepsGate = null, tool = 'animastor', comfyTried = [], platformComfy = false }) {
1439
1544
  const checks = [];
1440
1545
  const stats = comfyUrl ? await comfyui.systemStats(io, comfyUrl) : null;
1441
1546
  // Addresses in the result are always FULL (with the notebook prefix):
@@ -1456,12 +1561,38 @@ async function endToEndChecks(io, { mode, comfyUrl, comfyPort, hubUrl, workerWan
1456
1561
  ? `start your ComfyUI so that ${prefixed} answers, then run: ${tool} doctor`
1457
1562
  : `start your ComfyUI on port ${comfyPort || 8188}, then run: ${tool} doctor`,
1458
1563
  });
1564
+ // 0.2.13: the key and the protocol are matters of the HUB. Both used to be
1565
+ // reported as "Worker → ComfyUI: Worker Key rejected".
1566
+ const r = workerReady || {};
1567
+ const newKeyFix = `create a new Worker Key in Animastor → Settings → Workers, then run: ${tool} doctor --new-key`;
1568
+ const keyRejected = !!(keyCheck && keyCheck.status === 'rejected');
1569
+ const mismatch = !!(hubProtocol && hubProtocol.status === 'mismatch');
1570
+ const blocked = [];
1571
+ if (keyRejected || r.auth_failed) {
1572
+ const detail = (keyRejected ? keyCheck.reason : r.reason) || 'the Worker Key was rejected';
1573
+ checks.push({ id: 'hub-auth', ok: false, label: 'Worker → Hub (Worker Key)', detail: detail.replace(/\s+/g, ' '), fix: newKeyFix });
1574
+ blocked.push('the hub does not accept its Worker Key');
1575
+ }
1576
+ if (mismatch) {
1577
+ checks.push({ id: 'hub-protocol', ok: false, label: 'Worker → Hub (protocol)', detail: hubProtocol.reason, fix: hubProtocol.fix });
1578
+ blocked.push('the hub does not serve its job protocol');
1579
+ }
1580
+ if (nodeDepsGate && nodeDepsGate.failed) {
1581
+ checks.push({ id: 'node-deps', ok: false, label: 'Custom-node dependencies', detail: nodeDepsGate.reason, fix: nodeDepsGate.fix || null });
1582
+ blocked.push('the ComfyUI has no node classes for this profile');
1583
+ }
1584
+ if (workerWanted && blocked.length > 0) {
1585
+ checks.push(r.comfy_ready
1586
+ ? { id: 'worker', ok: true, label: 'Worker → ComfyUI', detail: '"ComfyUI ready" in the worker log', fix: null }
1587
+ : { id: 'worker', ok: null, label: 'Worker → ComfyUI', detail: `not checked — the worker does not run: ${blocked.join('; ')}`, fix: null });
1588
+ checks.push({ id: 'heartbeat', ok: null, label: 'Hub heartbeat (Online)', detail: 'not checked — the worker does not run', fix: null });
1589
+ return checks;
1590
+ }
1459
1591
  if (!workerWanted) {
1460
1592
  checks.push({ id: 'worker', ok: null, label: 'Worker → ComfyUI', detail: 'worker start skipped (--no-start-worker)', fix: `${tool} start` });
1461
1593
  checks.push({ id: 'heartbeat', ok: null, label: 'Hub heartbeat (Online)', detail: 'not checked — worker not started', fix: `${tool} start` });
1462
1594
  return checks;
1463
1595
  }
1464
- const newKeyFix = `create a new Worker Key in Animastor → Settings → Workers, then run: ${tool} doctor --new-key`;
1465
1596
  if (workerStart && workerStart.deferred) {
1466
1597
  // Installer 0.2.8: the worker keeps running (and serving) on its old
1467
1598
  // configuration; the needed restart was not done — FAILED, exit ≠ 0.
@@ -1475,7 +1606,6 @@ async function endToEndChecks(io, { mode, comfyUrl, comfyPort, hubUrl, workerWan
1475
1606
  checks.push({ id: 'heartbeat', ok: null, label: 'Hub heartbeat (Online)', detail: `not re-checked — the worker (pid ${workerStart.pid}) keeps running on its previous configuration`, fix: null });
1476
1607
  return checks;
1477
1608
  }
1478
- const r = workerReady || {};
1479
1609
  // A running worker left as is (installer 0.2.8) is not restarted by
1480
1610
  // another doctor run — the fix that restarts it is reboot-worker.
1481
1611
  const rerun = workerStart && workerStart.action === 'left' ? `${tool} reboot-worker` : `${tool} doctor`;
@@ -1485,18 +1615,24 @@ async function endToEndChecks(io, { mode, comfyUrl, comfyPort, hubUrl, workerWan
1485
1615
  const reason = (r.reason || (workerStart && workerStart.reason) || 'worker did not start').replace(/\s+/g, ' ');
1486
1616
  checks.push({
1487
1617
  id: 'worker', ok: false, label: 'Worker → ComfyUI', detail: reason,
1488
- fix: r.auth_failed ? newKeyFix : rerun,
1618
+ fix: rerun,
1489
1619
  });
1490
1620
  }
1491
1621
  if (r.heartbeat) {
1492
1622
  checks.push({ id: 'heartbeat', ok: true, label: 'Hub heartbeat (Online)', detail: hubUrl || null, fix: null });
1493
1623
  } else if (!r.comfy_ready) {
1494
- checks.push({ id: 'heartbeat', ok: false, label: 'Hub heartbeat (Online)', detail: 'not reached — the worker sends heartbeats only after it reached ComfyUI', fix: r.auth_failed ? newKeyFix : rerun });
1624
+ checks.push({ id: 'heartbeat', ok: false, label: 'Hub heartbeat (Online)', detail: 'not reached — the worker sends heartbeats only after it reached ComfyUI', fix: rerun });
1625
+ } else if (r.protocol_mismatch) {
1626
+ checks.push({
1627
+ id: 'heartbeat', ok: false, label: 'Worker → Hub (protocol)',
1628
+ detail: 'the hub has no route for the job protocol of this worker bundle (HTTP 404) — the Worker Key is not the cause',
1629
+ fix: 'run the install command from the Animastor setup page again (it brings the worker bundle of this hub); a new Worker Key does not help',
1630
+ });
1495
1631
  } else {
1496
1632
  checks.push({
1497
1633
  id: 'heartbeat', ok: false, label: 'Hub heartbeat (Online)',
1498
1634
  detail: (r.reason || 'no heartbeat confirmed').replace(/\s+/g, ' '),
1499
- fix: r.auth_failed ? newKeyFix : `check that this machine reaches ${hubUrl} (curl -fsS ${hubUrl}/health), then run: ${rerun}`,
1635
+ fix: `check that this machine reaches ${hubUrl} (curl -fsS ${hubUrl}/health), then run: ${rerun}`,
1500
1636
  });
1501
1637
  }
1502
1638
  return checks;
@@ -1553,7 +1689,32 @@ async function runVerification({ io, manifests, roots, options, log, crypto, tok
1553
1689
  // re-checked until the end of the wait window — not FAILED at once.
1554
1690
  const deadline = Number(options.nodeClassesDeadline) || 0;
1555
1691
  const pause = options.sleep || ((ms) => new Promise((r) => setTimeout(r, ms)));
1692
+ // Installer 0.2.5: say WHY (missing packages / IMPORT FAILED /
1693
+ // restart needed) — "run doctor" alone looped on the live node.
1694
+ const ownerInfo = options.comfyOwner || null;
1695
+ const diagnose = async (missing) => {
1696
+ const pid = ownerInfo && ownerInfo.pid ? ownerInfo.pid : null;
1697
+ const py = pid ? nodeDeps.pythonOfProcess(io, pid).python : null;
1698
+ let extraPaths = [];
1699
+ if (py && workerDir && ownerInfo && ownerInfo.owner === 'foreign') {
1700
+ const plan = pydeps.planPersistence(io, { python: py, root: comfyuiRoot, base: pydeps.overlayBase(workerDir), create: false });
1701
+ if (plan.kind === 'overlay' && plan.sitePackages && io.fs.existsSync(plan.sitePackages)) extraPaths = [plan.sitePackages];
1702
+ }
1703
+ const logFiles = [
1704
+ workerDir ? path.join(path.dirname(path.resolve(workerDir)), 'logs', 'comfyui-restart.log') : null,
1705
+ comfyuiRoot ? path.join(comfyuiRoot, 'comfyui-installer.log') : null,
1706
+ ].filter(Boolean);
1707
+ return nodeDeps.diagnoseMissingClasses(io, {
1708
+ missingClasses: missing, manifests, root: comfyuiRoot, url: baseUrl, pid, python: py, extraPaths, logFiles,
1709
+ });
1710
+ };
1711
+ let diag = null;
1556
1712
  if (missingClasses.length > 0 && deadline > io.now()) {
1713
+ // Missing packages never appear by waiting (0.2.13: 117 s lost).
1714
+ try { diag = await diagnose(missingClasses); } catch (_) { diag = null; }
1715
+ if (diag && diag.kind !== 'deps-missing') diag = null;
1716
+ }
1717
+ if (missingClasses.length > 0 && deadline > io.now() && !diag) {
1557
1718
  log.info(`node classes not registered yet (${missingClasses.join(', ')}) — re-checking for up to ${Math.round((deadline - io.now()) / 1000)} s`);
1558
1719
  while (missingClasses.length > 0 && io.now() < deadline) {
1559
1720
  await pause(Math.min(options.pollIntervalMs || 3000, Math.max(1, deadline - io.now())));
@@ -1564,24 +1725,8 @@ async function runVerification({ io, manifests, roots, options, log, crypto, tok
1564
1725
  }
1565
1726
  if (missingClasses.length > 0) {
1566
1727
  live.comfyui.missing_node_classes = missingClasses;
1567
- // Installer 0.2.5: say WHY (missing packages / IMPORT FAILED /
1568
- // restart needed) — "run doctor" alone looped on the live node.
1569
1728
  try {
1570
- const ownerInfo = options.comfyOwner || null;
1571
- const pid = ownerInfo && ownerInfo.pid ? ownerInfo.pid : null;
1572
- const py = pid ? nodeDeps.pythonOfProcess(io, pid).python : null;
1573
- let extraPaths = [];
1574
- if (py && workerDir && ownerInfo && ownerInfo.owner === 'foreign') {
1575
- const plan = pydeps.planPersistence(io, { python: py, root: comfyuiRoot, base: pydeps.overlayBase(workerDir), create: false });
1576
- if (plan.kind === 'overlay' && plan.sitePackages && io.fs.existsSync(plan.sitePackages)) extraPaths = [plan.sitePackages];
1577
- }
1578
- const logFiles = [
1579
- workerDir ? path.join(path.dirname(path.resolve(workerDir)), 'logs', 'comfyui-restart.log') : null,
1580
- comfyuiRoot ? path.join(comfyuiRoot, 'comfyui-installer.log') : null,
1581
- ].filter(Boolean);
1582
- const diag = await nodeDeps.diagnoseMissingClasses(io, {
1583
- missingClasses, manifests, root: comfyuiRoot, url: baseUrl, pid, python: py, extraPaths, logFiles,
1584
- });
1729
+ diag = diag || await diagnose(missingClasses);
1585
1730
  live.comfyui.missing_node_classes_cause = {
1586
1731
  kind: diag.kind, detail: diag.detail, log_source: diag.log_source,
1587
1732
  owner: ownerInfo && ownerInfo.owner === 'foreign' ? 'foreign' : 'managed',
@@ -1628,6 +1773,7 @@ async function runVerification({ io, manifests, roots, options, log, crypto, tok
1628
1773
  const reg = await worker.verifyRegistration(io, { hubUrl, token, expectedType });
1629
1774
  emit('registration', { registered: reg.registered, worker_id: reg.worker_id || null, worker_type: reg.worker_type || null, reason: reg.reason || null });
1630
1775
  live.worker = { process_alive: null, registered: reg.registered === true };
1776
+ if (!reg.registered) live.registration_cause = { kind: [401, 403].includes(reg.status_code) ? 'key' : 'hub', detail: reg.reason };
1631
1777
  live.hub = { connection: reg.reason ? reg.reason.indexOf('unreachable') === -1 : true, registration: reg.registered === true };
1632
1778
  if (!reg.registered) {
1633
1779
  log.warn('Installation completed locally, but Worker registration failed. The installed environment is intact — fix the credential/network and re-run `verify`.');
@@ -1655,7 +1801,9 @@ async function runVerification({ io, manifests, roots, options, log, crypto, tok
1655
1801
  }
1656
1802
 
1657
1803
  // Re-probe disk state for the final report
1658
- const envAfter = probe.probeEnvironment(io, { root: comfyuiRoot, workerDir, crypto, workerType: expectedType });
1804
+ const envAfter = await probe.hashProbedModels(io, probe.probeEnvironment(io, {
1805
+ root: comfyuiRoot, workerDir, crypto, workerType: expectedType, manifests,
1806
+ }), manifests);
1659
1807
  const reportAfter = require('../compatibility-resolver').resolveInstallation({
1660
1808
  manifests, environment: envAfter, mode: manifests.length > 1 ? 'shared' : 'existing',
1661
1809
  });
@@ -0,0 +1,134 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Hub preflight (installer 0.2.13) — BEFORE the worker is started:
5
+ *
6
+ * 1. Worker Key: the same call the worker makes at its start
7
+ * (POST <api>/worker/verify, Bearer, {worker_version}). A revoked key kept
8
+ * in .env used to be "preserved" and failed only at `start worker`.
9
+ * 2. Job protocol: does the hub serve a protocol this worker bundle speaks?
10
+ *
11
+ * Only an explicit 401/403 means a bad key. A network error, a 5xx answer or a
12
+ * missing endpoint is never blamed on the key, and no new key is asked for.
13
+ *
14
+ * The protocol probe sends NO credential: the hub checks the key before
15
+ * anything else, so it can neither claim a task nor write a heartbeat.
16
+ */
17
+
18
+ const path = require('path');
19
+ const { apiBaseFromHubUrl, readEnvValues, readPkgVersion } = require('./worker');
20
+
21
+ const TOKEN_KEY = 'ANIMASTOR_WORKER_TOKEN';
22
+ const TIMEOUT_MS = 15000;
23
+ const MAX_KEY_ATTEMPTS = 3;
24
+
25
+ /** Worker route of each job protocol. */
26
+ const PROTOCOL_ROUTES = Object.freeze({ 3: '/v3/task/next', 2: '/task/next' });
27
+
28
+ /** What the worker will really use: .env first, then this run's values. */
29
+ function workerHubTargets(io, { workerDir, hubUrl = null, hubUrlExplicit = false }) {
30
+ const env = workerDir ? readEnvValues(io, workerDir, { skip: [] }) : {};
31
+ const hub = String((hubUrlExplicit && hubUrl) || env.HUB_URL || hubUrl || '').replace(/\/+$/, '');
32
+ return {
33
+ hubUrl: hub || null,
34
+ apiUrl: env.ANIMASTOR_API_URL || (hub ? apiBaseFromHubUrl(hub) : null),
35
+ token: env[TOKEN_KEY] || null,
36
+ };
37
+ }
38
+
39
+ /**
40
+ * @returns {Promise<{ status: 'accepted'|'rejected'|'unreachable'|'unavailable'|'protocol', http_status: number|null, reason: string|null }>}
41
+ */
42
+ async function checkWorkerKey(io, { apiUrl, token, workerVersion = null }) {
43
+ const url = `${apiUrl}/worker/verify`;
44
+ let res;
45
+ try {
46
+ res = await io.http.fetchJson(url, {
47
+ method: 'POST',
48
+ headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
49
+ body: JSON.stringify({ worker_version: workerVersion }),
50
+ signal: AbortSignal.timeout(TIMEOUT_MS),
51
+ });
52
+ } catch (err) {
53
+ return { status: 'unreachable', http_status: null, reason: `${url} is not reachable: ${err.message}` };
54
+ }
55
+ const out = (status, reason) => ({ status, http_status: res.status, reason });
56
+ if (res.status === 200 && res.json && res.json.verified === true) return out('accepted', null);
57
+ if (res.status === 401 || res.status === 403) {
58
+ // the backend's own failure, not a verdict about the key
59
+ if (res.json && res.json.code === 'worker_auth_failed') return out('unavailable', `${url} could not check the key (HTTP ${res.status})`);
60
+ return out('rejected', `Animastor rejected the Worker Key (HTTP ${res.status}): it is revoked or wrong`);
61
+ }
62
+ if (res.status === 404 || res.status === 405) return out('protocol', `${url} does not exist on this server (HTTP ${res.status}) — HUB_URL is wrong or the server and the worker are of different releases`);
63
+ return out('unavailable', `${url} answered HTTP ${res.status}`);
64
+ }
65
+
66
+ /**
67
+ * Check the key; a rejected one is asked for again when `ask` is given
68
+ * (interactive run only) and every answer is checked before it is accepted.
69
+ * @param {Function|null} o.ask async ({ reason, attempt }) => new key | null
70
+ * @returns {Promise<{ status: string, reason: string|null, token: string|null, replaced: boolean }>}
71
+ */
72
+ async function ensureWorkerKey(io, { apiUrl, token, workerVersion = null, ask = null, log = null }) {
73
+ if (!token || !apiUrl) return { status: 'skipped', reason: null, token: token || null, replaced: false };
74
+ let current = token;
75
+ let replaced = false;
76
+ let res = await checkWorkerKey(io, { apiUrl, token: current, workerVersion });
77
+ for (let attempt = 1; res.status === 'rejected' && ask && attempt <= MAX_KEY_ATTEMPTS; attempt++) {
78
+ if (log) log.warn(res.reason);
79
+ const fresh = await ask({ reason: res.reason, attempt });
80
+ if (!fresh) break;
81
+ if (log && log.registerSecret) log.registerSecret(fresh);
82
+ current = fresh;
83
+ replaced = true;
84
+ res = await checkWorkerKey(io, { apiUrl, token: current, workerVersion });
85
+ }
86
+ if (log) {
87
+ if (res.status === 'accepted') log.info(`Worker Key accepted by Animastor${replaced ? ' (new key)' : ''}`);
88
+ else if (res.status === 'rejected') log.error(res.reason);
89
+ else log.warn(`Worker Key not checked: ${res.reason} — this says nothing about the key, it is kept`);
90
+ }
91
+ return { status: res.status, reason: res.reason, token: current, replaced: replaced && res.status !== 'rejected' };
92
+ }
93
+
94
+ /** Job protocols the bundle on disk speaks ([] = cannot tell). */
95
+ function workerProtocols(io, workerDir) {
96
+ let src = '';
97
+ try { src = String(io.fs.readFileSync(path.join(workerDir, 'worker.cjs'), 'utf8')); } catch (_) { return []; }
98
+ const out = [];
99
+ if (src.includes(PROTOCOL_ROUTES[3])) out.push(3);
100
+ if (io.fs.existsSync(path.join(workerDir, 'job-protocol-v2.cjs'))) out.push(2);
101
+ return out;
102
+ }
103
+
104
+ /**
105
+ * @returns {Promise<{ status: 'ok'|'mismatch'|'unreachable'|'unknown', worker: number[], hub: number[], reason: string|null, fix: string|null }>}
106
+ */
107
+ async function checkHubProtocol(io, { hubUrl, workerDir }) {
108
+ const worker = workerProtocols(io, workerDir);
109
+ const result = (status, hub, reason = null, fix = null) => ({ status, worker, hub, reason, fix });
110
+ if (!hubUrl || worker.length === 0) return result('unknown', []);
111
+ const statusOf = async (route) => (await io.http.fetchJson(`${hubUrl}${route}`, { signal: AbortSignal.timeout(TIMEOUT_MS) })).status;
112
+ const hub = [];
113
+ try {
114
+ // the worker's own protocols first: one request when they match
115
+ const order = [...worker, ...[3, 2].filter((p) => !worker.includes(p))];
116
+ for (const p of order) {
117
+ const s = await statusOf(PROTOCOL_ROUTES[p]);
118
+ if (s >= 500) return result('unreachable', hub, `the hub ${hubUrl} answered HTTP ${s}`);
119
+ if (s !== 404) hub.push(p);
120
+ if (hub.some((x) => worker.includes(x))) return result('ok', hub);
121
+ }
122
+ const health = await statusOf('/health');
123
+ if (health !== 200) return result('unreachable', hub, `${hubUrl} does not answer as an Animastor hub (GET /health → HTTP ${health}) — check HUB_URL`);
124
+ } catch (err) {
125
+ return result('unreachable', hub, `the hub ${hubUrl} is not reachable: ${err.message}`);
126
+ }
127
+ const version = readPkgVersion(io, workerDir);
128
+ const speaks = hub.length > 0 ? `serves protocol ${hub.join(', ')}` : 'serves none of the protocols this installer knows';
129
+ return result('mismatch', hub,
130
+ `worker bundle ${version || 'unknown'} speaks job protocol ${worker.join(', ')}, but the hub ${hubUrl} ${speaks} — the Worker Key is not the cause`,
131
+ 'run the install command from the Animastor setup page again (it brings the worker bundle of this hub); a new Worker Key does not help');
132
+ }
133
+
134
+ module.exports = { TOKEN_KEY, workerHubTargets, checkWorkerKey, ensureWorkerKey, workerProtocols, checkHubProtocol };
@@ -16,12 +16,14 @@ const { redactSecrets, isSecretName } = require('../safety-rules');
16
16
  function createLogger({ io, sink = null, quiet = false } = {}) {
17
17
  const secrets = new Set();
18
18
  const lines = [];
19
+ let tee = null;
19
20
 
20
21
  function emit(level, msg) {
21
22
  const safe = redact(String(msg), secrets);
22
23
  const ts = new Date(io.now()).toISOString();
23
24
  const line = `[${ts}] [${level}] ${safe}`;
24
25
  lines.push(line);
26
+ if (tee) tee(line);
25
27
  if (!quiet) {
26
28
  if (sink) sink(line);
27
29
  else console.log(line); // eslint-disable-line no-console
@@ -67,6 +69,11 @@ function createLogger({ io, sink = null, quiet = false } = {}) {
67
69
  return { ok: false, error: err, ms: io.now() - t0 };
68
70
  }
69
71
  },
72
+ /** Copy the log to fn: the lines so far, then every new one (redacted). */
73
+ teeTo(fn) {
74
+ lines.forEach((line) => fn(line));
75
+ tee = fn;
76
+ },
70
77
  lines,
71
78
  isSecretName,
72
79
  };
@@ -209,7 +209,7 @@ function installNodeDeps(io, { python, nodes, torch = {}, constraintsPath = null
209
209
  r = io.exec(python, [...args, '--user'], { timeout: 60 * 60 * 1000 });
210
210
  }
211
211
  if (r.code === 0) installed.push(n.directory);
212
- else failed.push({ directory: n.directory, reason: `pip install -r ${n.reqPath} failed: ${String(r.stderr || r.error || '').slice(-300)}` });
212
+ else failed.push({ directory: n.directory, output: `${r.stdout || ''}\n${r.stderr || ''}`, reason: `pip install -r ${n.reqPath} failed: ${String(r.stderr || r.error || '').slice(-300)}` });
213
213
  }
214
214
  return { ok: failed.length === 0, installed, failed, target: pipPython ? 'overlay' : 'system' };
215
215
  }
@@ -42,9 +42,9 @@ function pipInstallRequirements(io, { root, reqPath, python, torchSpec, log = nu
42
42
  const r = io.exec(python, args, { timeout: 60 * 60 * 1000 });
43
43
  if (r.code !== 0) {
44
44
  if (log) log.warn(`pip install -r requirements.txt failed: ${String(r.stderr).slice(-300)}`);
45
- return false;
45
+ return { ok: false, output: `${r.stdout || ''}\n${r.stderr || ''}` };
46
46
  }
47
- return true;
47
+ return { ok: true, output: '' };
48
48
  }
49
49
 
50
50
  /**
@@ -79,10 +79,9 @@ function installCustomNode(io, { root, dep, python = null, torchSpec = null, ret
79
79
  // be completed (pip is idempotent and never removes anything).
80
80
  if (retryDeps && python) {
81
81
  const req = path.join(target, 'requirements.txt');
82
- if (io.fs.existsSync(req) && pipInstallRequirements(io, { root, reqPath: req, python, torchSpec, log })) {
83
- return { status: 'installed', origin: 'pre-existing', directory: dirName, reason: null };
84
- }
85
- return { status: 'installed', origin: 'pre-existing', directory: dirName, reason: 'already present; python dependencies incomplete — see warnings' };
82
+ const pip = io.fs.existsSync(req) ? pipInstallRequirements(io, { root, reqPath: req, python, torchSpec, log }) : { ok: false, output: '' };
83
+ if (pip.ok) return { status: 'installed', origin: 'pre-existing', directory: dirName, reason: null };
84
+ return { status: 'installed', origin: 'pre-existing', directory: dirName, pip_output: pip.output, reason: 'already present; python dependencies incomplete — see warnings' };
86
85
  }
87
86
  return { status: 'installed', origin: 'pre-existing', directory: dirName, reason: 'already present — kept as-is' };
88
87
  }
@@ -137,8 +136,9 @@ function installCustomNode(io, { root, dep, python = null, torchSpec = null, ret
137
136
 
138
137
  const req = path.join(target, 'requirements.txt');
139
138
  if (io.fs.existsSync(req) && python) {
140
- if (!pipInstallRequirements(io, { root, reqPath: req, python, torchSpec, log })) {
141
- return { status: 'installed', origin: 'installed', directory: dirName, reason: 'cloned; python dependencies incomplete — see warnings' };
139
+ const pip = pipInstallRequirements(io, { root, reqPath: req, python, torchSpec, log });
140
+ if (!pip.ok) {
141
+ return { status: 'installed', origin: 'installed', directory: dirName, pip_output: pip.output, reason: 'cloned; python dependencies incomplete — see warnings' };
142
142
  }
143
143
  }
144
144
 
@@ -544,6 +544,32 @@ function checkOwnership(io, { paths = [], home = null, currentUid: uidInput = nu
544
544
  return { ok: violations.length === 0, violations };
545
545
  }
546
546
 
547
+ const BUILD_FAILURE_RE = /failed building wheel|could not build wheels|metadata-generation-failed|unable to execute '[^']*(gcc|cc|g\+\+)'|command '[^']*(gcc|cc|g\+\+)' failed|(Python|sndfile)\.h: No such file|No such file or directory: '[^']*(gcc|cc|g\+\+)'/i;
548
+
549
+ /**
550
+ * Host build packages are required ONLY when pip had to build a package from
551
+ * source (no wheel for this platform) and that build failed (installer
552
+ * 0.2.13): with a wheel pip never runs a compiler, and an up-front "install
553
+ * build-essential libsndfile1-dev" was a false ✗.
554
+ * @param {string} output pip output of the failed install
555
+ * @returns {{ code, summary, package, command }|null}
556
+ */
557
+ function buildToolsRemediation(io, { output, python = 'python3', platformAdapter = null }) {
558
+ const text = String(output || '');
559
+ if (!BUILD_FAILURE_RE.test(text)) return null;
560
+ const adapter = adapterOf({ platformAdapter });
561
+ const check = adapter.checkBuildPrerequisites(io, { python });
562
+ const missing = (check.missing || []).filter((m) => m.pkg !== 'libsndfile1-dev' || /sndfile/i.test(text));
563
+ if (check.ok || missing.length === 0) return null;
564
+ const pkgs = missing.map((m) => m.pkg).join(' ');
565
+ return {
566
+ code: 'MISSING_BUILD_TOOLS',
567
+ summary: 'a Python package has no wheel for this platform and could not be built from source',
568
+ package: pkgs,
569
+ command: adapter.hostPackagesCommand(pkgs),
570
+ };
571
+ }
572
+
547
573
  /**
548
574
  * Check for C build tools required by packages with native extensions
549
575
  * (funasr, soundfile, etc.). Delegates to the platform adapter — the
@@ -569,6 +595,7 @@ module.exports = {
569
595
  renderRemediation,
570
596
  checkPythonPrerequisites,
571
597
  checkBuildPrerequisites,
598
+ buildToolsRemediation,
572
599
  checkOwnership,
573
600
  currentUid,
574
601
  currentHome,
@@ -417,10 +417,29 @@ function extraModelFolders(io, root) {
417
417
  }
418
418
  }
419
419
 
420
- function probeModels(io, root) {
420
+ /**
421
+ * Folders scanned for models: MODEL_DIRS plus the top folder (models/<folder>)
422
+ * of every target_dir the manifests install models into — a file the
423
+ * downloader can write is always a file the check can see (0.2.14).
424
+ */
425
+ function modelScanDirs(manifests = []) {
426
+ const dirs = new Set(MODEL_DIRS);
427
+ for (const m of manifests || []) {
428
+ for (const dep of m.dependencies || []) {
429
+ if (dep.kind !== 'model' && dep.kind !== 'model_repo') continue;
430
+ const parts = String(dep.target_dir || '').split(/[\\/]+/).filter((p) => p && p !== '.');
431
+ if (parts.length < 2 || parts.includes('..')) continue;
432
+ dirs.add(parts.slice(0, 2).join('/'));
433
+ }
434
+ }
435
+ return [...dirs];
436
+ }
437
+
438
+ function probeModels(io, root, manifests = []) {
421
439
  const out = [];
422
- for (const dir of MODEL_DIRS) walkModelDir(io, path.join(root, dir), dir, out);
423
- const seen = new Set(MODEL_DIRS.map((d) => path.normalize(path.join(root, d))));
440
+ const scanDirs = modelScanDirs(manifests);
441
+ for (const dir of scanDirs) walkModelDir(io, path.join(root, dir), dir, out);
442
+ const seen = new Set(scanDirs.map((d) => path.normalize(path.join(root, d))));
424
443
  for (const extra of extraModelFolders(io, root)) {
425
444
  const abs = extra.path.replace(/[\\/]+$/, '');
426
445
  if (seen.has(path.normalize(abs))) continue; // same as the default layout
@@ -430,6 +449,34 @@ function probeModels(io, root) {
430
449
  return out;
431
450
  }
432
451
 
452
+ /** Larger files are checked by size only: hashing 20+ GB on every doctor run takes minutes. */
453
+ const HASH_LIMIT_BYTES = 1024 ** 3;
454
+
455
+ /**
456
+ * Add sha256 to the probed models the manifests carry a checksum for, so the
457
+ * resolver can say "checksum-verified" (0.2.14). Only files of exactly the
458
+ * manifest size are hashed: another size is another file (quant) and stays a
459
+ * matter of the size check. An unreadable file stays without sha256.
460
+ */
461
+ async function hashProbedModels(io, env, manifests = []) {
462
+ if (!env || !env.root || !Array.isArray(env.models) || !io.hashFile) return env;
463
+ const byPath = new Map(env.models.map((m) => [m.path, m]));
464
+ for (const dep of (manifests || []).flatMap((m) => m.dependencies || [])) {
465
+ if (dep.kind !== 'model' || !dep.checksum || !dep.checksum.value) continue;
466
+ const found = byPath.get(path.posix.join(dep.target_dir, dep.filename));
467
+ if (!found || found.sha256 || found.size_bytes !== dep.size_bytes_approx || found.size_bytes > HASH_LIMIT_BYTES) continue;
468
+ try { found.sha256 = await io.hashFile(modelAbsPath(env.root, found), 'sha256'); } catch (_) { /* size check only */ }
469
+ }
470
+ return env;
471
+ }
472
+
473
+ /** Absolute path of a probed model (`location` = a folder of extra_model_paths.yaml). */
474
+ function modelAbsPath(root, model) {
475
+ return model.location
476
+ ? path.join(model.location, model.path.split('/').slice(2).join('/'))
477
+ : path.join(root, model.path);
478
+ }
479
+
433
480
  function sha256OfFile(io, crypto, absPath) {
434
481
  const data = io.fs.readFileSync(absPath); // workflows are small; fine
435
482
  return crypto.createHash('sha256').update(Buffer.from(data)).digest('hex');
@@ -490,10 +537,10 @@ function probeWorker(io, workerDir) {
490
537
  /**
491
538
  * Probe the full environment.
492
539
  * @param {object} io
493
- * @param {object} opts { root: ComfyUI root, workerDir, crypto }
540
+ * @param {object} opts { root: ComfyUI root, workerDir, crypto, manifests: loaded manifests (model folders) }
494
541
  * @returns resolver-compatible environment object
495
542
  */
496
- function probeEnvironment(io, { root = null, workerDir = null, crypto = null, workerType = null } = {}) {
543
+ function probeEnvironment(io, { root = null, workerDir = null, crypto = null, workerType = null, manifests = [] } = {}) {
497
544
  const env = {
498
545
  root,
499
546
  comfyui: undefined,
@@ -526,7 +573,7 @@ function probeEnvironment(io, { root = null, workerDir = null, crypto = null, wo
526
573
 
527
574
  if (env.comfyui) {
528
575
  env.custom_nodes = probeCustomNodes(io, root);
529
- env.models = probeModels(io, root);
576
+ env.models = probeModels(io, root, manifests);
530
577
  env.python_packages = [];
531
578
  if (crypto) env.workflows = probeWorkflows(io, crypto, root);
532
579
  } else {
@@ -595,6 +642,9 @@ module.exports = {
595
642
  MODEL_DIRS,
596
643
  parseExtraModelPaths,
597
644
  probeModels,
645
+ modelScanDirs,
646
+ hashProbedModels,
647
+ modelAbsPath,
598
648
  pickNodeBinary,
599
649
  nodeBinaryVersion,
600
650
  nodeMajor,
@@ -50,6 +50,8 @@ function fixForCheck(check, { tool = 'animastor', mode = null } = {}) {
50
50
  return mode === 'managed' ? `${tool} start` : `start your ComfyUI, then run: ${tool} doctor`;
51
51
  case 'Worker registration':
52
52
  case 'GPU Hub registration':
53
+ // 0.2.13: only a 401/403 is answered with a new key
54
+ if (check.cause && check.cause.kind === 'hub') return `check that this machine reaches the hub (the Worker Key is not the cause), then run: ${tool} doctor`;
53
55
  return `create a new Worker Key in Animastor → Settings → Workers, then run: ${tool} doctor --new-key`;
54
56
  case 'Worker process':
55
57
  return `${tool} start`;
@@ -87,14 +89,16 @@ const COVERED_BY_E2E = new Set(['ComfyUI running', 'ComfyUI API', 'Worker proces
87
89
  * @param {Array} [args.extra] - additional { ok, label, detail, fix } items (blocked steps, remediation)
88
90
  * @returns {{ ok: boolean, text: string, failures: Array }}
89
91
  */
90
- function renderFinalSummary({ verification = null, e2e = [], extra = [], tool = 'animastor', mode = null } = {}) {
92
+ function renderFinalSummary({ verification = null, e2e = [], extra = [], tool = 'animastor', mode = null, comfyPid = null } = {}) {
91
93
  const items = [];
92
94
  for (const c of extra || []) items.push(c);
95
+ const keyReported = (e2e || []).some((c) => c.id === 'hub-auth' && c.ok === false);
93
96
  const e2eIds = new Set((e2e || []).map((c) => c.label));
94
97
  for (const c of (verification && verification.checks) || []) {
95
98
  if (c.verdict !== false) continue;
96
99
  if (COVERED_BY_E2E.has(c.label) && e2e && e2e.length > 0) continue;
97
100
  if (e2eIds.has(c.label)) continue;
101
+ if (keyReported && /^(Worker|GPU Hub) registration$/.test(c.label)) continue;
98
102
  items.push({ ok: false, label: c.label, detail: c.detail, fix: fixForCheck(c, { tool, mode }) });
99
103
  }
100
104
  for (const c of e2e || []) items.push(c);
@@ -107,6 +111,8 @@ function renderFinalSummary({ verification = null, e2e = [], extra = [], tool =
107
111
  const mark = c.ok === true ? '✓' : c.ok === false ? '✗' : c.ok === 'info' ? '[i]' : c.ok === 'warn' ? '!' : '·';
108
112
  lines.push(`${mark} ${c.label}${c.detail ? `: ${oneLine(c.detail)}` : ''}`);
109
113
  if (c.ok === false && c.fix) lines.push(` fix: ${c.fix}`);
114
+ const note = c.ok === false ? foreignRestartNote(c.fix, comfyPid) : null;
115
+ if (note) lines.push(` ${note}`);
110
116
  }
111
117
  lines.push('');
112
118
  if (failures.length === 0) {
@@ -117,8 +123,18 @@ function renderFinalSummary({ verification = null, e2e = [], extra = [], tool =
117
123
  return { ok: failures.length === 0, text: lines.join('\n'), failures };
118
124
  }
119
125
 
126
+ /**
127
+ * A fix with --restart-platform-comfy stops a process the installer did not
128
+ * start: said next to EVERY such fix (0.2.13), the command itself stays
129
+ * copy-pasteable.
130
+ */
131
+ function foreignRestartNote(fix, pid = null) {
132
+ if (!/--restart-platform-comfy/.test(String(fix || ''))) return null;
133
+ return `WARNING: --restart-platform-comfy restarts a ComfyUI that was started outside the installer${pid ? ` (pid ${pid})` : ''} — someone else's process; its running and queued jobs are lost`;
134
+ }
135
+
120
136
  function oneLine(s) {
121
137
  return String(s).replace(/\s+/g, ' ').trim();
122
138
  }
123
139
 
124
- module.exports = { renderBanner, renderFinalSummary, fixForCheck, BANNER };
140
+ module.exports = { renderBanner, renderFinalSummary, foreignRestartNote, fixForCheck, BANNER };
@@ -739,6 +739,8 @@ function scanWorkerLog(text) {
739
739
  // beacon failure (the worker re-logs the marker after a recovery).
740
740
  heartbeat: lastIdx(/Hub heartbeat accepted/) > beaconErrIdx,
741
741
  auth_failed: find(/Worker authentication failed/),
742
+ // 0.2.13: HTTP 404 from the hub's job routes = another protocol, not a bad key
743
+ protocol_mismatch: find(/Hub protocol 3 unavailable \(HTTP 404\)|Hub rejected beacon: HTTP 404/),
742
744
  crashed: find(/Worker crashed/),
743
745
  last_comfy_error: comfyErr ? comfyErr.replace(/^\[[^\]]*\]\s*\[[^\]]*\]\s*/, '') : null,
744
746
  last_beacon_error: beaconErrIdx >= 0 ? (lines[beaconErrIdx + 1] || lines[beaconErrIdx]).trim() : null,
@@ -914,7 +916,7 @@ async function waitForWorkerReady(io, { workerDir, pid = null, logFile = null, l
914
916
  }
915
917
 
916
918
  function flags(scan) {
917
- return { comfy_ready: scan.comfy_ready, heartbeat: scan.heartbeat, auth_failed: scan.auth_failed };
919
+ return { comfy_ready: scan.comfy_ready, heartbeat: scan.heartbeat, auth_failed: scan.auth_failed, protocol_mismatch: scan.protocol_mismatch };
918
920
  }
919
921
 
920
922
  /** Grace sleep through the adapter (test-injectable `sleep` command wins). */
@@ -722,7 +722,12 @@ function renderPlanText(plan, report, { questions = true, header = true } = {})
722
722
  lines.push('');
723
723
  }
724
724
 
725
- const actions = report.entries.filter((e) => e.action === 'install').map(actionLine);
725
+ // 0.2.13: "Actions" lists only what WILL run. Steps declined in an
726
+ // earlier run used to be listed here and then silently skipped.
727
+ const declined = new Set();
728
+ for (const s of plan.steps) if (s.skipped_by_user) for (const x of s.missing || []) declined.add(x.id);
729
+ const toInstall = report.entries.filter((e) => e.action === 'install');
730
+ const actions = toInstall.filter((e) => !declined.has(e.id)).map(actionLine);
726
731
  for (const e of report.entries) {
727
732
  if (e.action === 'configure') actions.push(`Configure ${entryLabel(e)} (.env)`);
728
733
  }
@@ -732,9 +737,16 @@ function renderPlanText(plan, report, { questions = true, header = true } = {})
732
737
  lines.push('');
733
738
  }
734
739
 
740
+ const skipped = toInstall.filter((e) => declined.has(e.id));
741
+ if (skipped.length > 0) {
742
+ lines.push('Declined earlier (will NOT be done):');
743
+ for (const e of skipped) lines.push(` ${actionLine(e)}`);
744
+ lines.push('');
745
+ }
746
+
735
747
  // Download size summary — what will REALLY be downloaded: the missing
736
748
  // files of incomplete repos, the full size only for absent models.
737
- const toDownload = report.entries.filter((e) => (e.kind === 'model' || e.kind === 'model_repo') && e.status === 'missing' && e.action === 'install');
749
+ const toDownload = report.entries.filter((e) => (e.kind === 'model' || e.kind === 'model_repo') && e.status === 'missing' && e.action === 'install' && !declined.has(e.id));
738
750
  if (toDownload.length > 0) {
739
751
  const est = {
740
752
  total_bytes: toDownload.reduce((a, e) => a + (typeof e.missing_bytes_approx === 'number' ? e.missing_bytes_approx : 0), 0),
@@ -204,10 +204,11 @@ function buildVerificationReport({ report, live = {} }) {
204
204
  push(false, 'Worker .env / Worker Key', missingKeys ? `configuration incomplete: ${missingKeys}` : 'interactive setup required');
205
205
  }
206
206
 
207
+ const regCause = live.registration_cause ? { cause: live.registration_cause } : null;
207
208
  if (live.worker) {
208
209
  const wk = live.worker;
209
210
  push(tri(wk.process_alive), 'Worker process');
210
- push(tri(wk.registered), 'Worker registration');
211
+ push(tri(wk.registered), 'Worker registration', null, regCause);
211
212
  if (wk.health !== undefined) push(tri(wk.health), 'Worker health');
212
213
  } else {
213
214
  push(null, 'Worker process / registration', 'not checked');
@@ -215,7 +216,7 @@ function buildVerificationReport({ report, live = {} }) {
215
216
 
216
217
  if (live.hub) {
217
218
  push(tri(live.hub.connection), 'GPU Hub connection');
218
- push(tri(live.hub.registration), 'GPU Hub registration');
219
+ push(tri(live.hub.registration), 'GPU Hub registration', live.registration_cause ? live.registration_cause.detail : null, regCause);
219
220
  } else {
220
221
  push(null, 'GPU Hub registration', 'not checked');
221
222
  }