@animastor/installer 0.2.12 → 0.2.13

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.13, 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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@animastor/installer",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
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 },
@@ -1351,7 +1368,7 @@ async function cmdInstall(flags, { doctor = false } = {}) {
1351
1368
  // its models already in place needs none). Previously answered steps
1352
1369
  // (a declined optional workflow, a declined model download) are not
1353
1370
  // asked again.
1354
- const priorDecisions = priorReusableDecisions(priorState);
1371
+ const priorDecisions = applicableDecisions(priorState, { doctor, yes });
1355
1372
  const { plan, report: planReport } = await resolveAndPlanWithSizes({ io: realIo, manifests: loadedManifests, env, mode, decisions: priorDecisions });
1356
1373
 
1357
1374
  // Prerequisites & ownership BEFORE any prompt/change: a missing
@@ -1469,10 +1486,9 @@ async function cmdInstall(flags, { doctor = false } = {}) {
1469
1486
  const secrets = {};
1470
1487
 
1471
1488
  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.
1489
+ // --yes answers everything EXCEPT what is still declined for this run
1490
+ // (see applicableDecisions): optional workflows always, model/node
1491
+ // downloads only for the unattended `doctor --yes`.
1476
1492
  const yd = yesDecisions();
1477
1493
  for (const k of ['workflows', 'install_models', 'install_custom_nodes']) {
1478
1494
  if (priorDecisions[k] !== undefined) yd[k] = priorDecisions[k];
@@ -1570,6 +1586,19 @@ async function cmdInstall(flags, { doctor = false } = {}) {
1570
1586
  hubUrlExplicit: !!flags['hub-url'],
1571
1587
  nodeBinary: nodePick,
1572
1588
  replaceWorkerKey,
1589
+ // 0.2.13: only an interactive run may ask for a new Worker Key
1590
+ askWorkerKey: prompt.available && !yes && !boot
1591
+ ? () => prompt.secret('The Worker Key is revoked or wrong. Paste a new Worker Key from Animastor → Settings → Workers (hidden input, Enter = skip)')
1592
+ : null,
1593
+ // 0.2.13: the node-deps gate again, for nodes installed by this run
1594
+ platformNodeDeps: async (current) => {
1595
+ const g = await platformNodeDepsGate(realIo, {
1596
+ instance: current, state: stateStore.loadState(realIo, statePath), root, manifests: loadedManifests, flags, boot, yes, prompt,
1597
+ waitMs: Math.max(180000, comfyWaitMs), logger, statePath, workerDir,
1598
+ otherManifests: otherProfileManifests(priorState, flags.profiles, { logger }), command: doctor ? 'doctor' : 'install',
1599
+ });
1600
+ return { ...g, ownedServices: nodeDepsOwnedServices(g) };
1601
+ },
1573
1602
  comfyOwner: instance,
1574
1603
  comfyWaitMs,
1575
1604
  nodeClassesDeadline,
@@ -1581,7 +1610,7 @@ async function cmdInstall(flags, { doctor = false } = {}) {
1581
1610
  hubVersion,
1582
1611
  },
1583
1612
  });
1584
- printResult(withPre({ ...result, node_deps_overrides: depsGate ? depsGate.overrides : [] }), { flags, mode, boot, hubVersion });
1613
+ printResult(withPre({ ...result, node_deps_overrides: result.results.node_deps_overrides || (depsGate ? depsGate.overrides : []) }), { flags, mode, boot, hubVersion });
1585
1614
  } catch (err) {
1586
1615
  if (err instanceof NoTerminalError) {
1587
1616
  console.error('');
@@ -1884,7 +1913,11 @@ function printOneLineSummary(result, { flags = {}, mode = null } = {}) {
1884
1913
  const head = summary.ok ? 'OK' : `FAILED — ${summary.failures.length} problem(s)`;
1885
1914
  console.log(`animastor doctor: ${head} — ${what} (${tool})`);
1886
1915
  if (!summary.ok) {
1887
- for (const f of summary.failures) console.log(` ✗ ${f.label}: ${f.detail || ''}${f.fix ? ` — fix: ${f.fix}` : ''}`);
1916
+ for (const f of summary.failures) {
1917
+ console.log(` ✗ ${f.label}: ${f.detail || ''}${f.fix ? ` — fix: ${f.fix}` : ''}`);
1918
+ const note = foreignRestartNote(f.fix, owner && owner.pid);
1919
+ if (note) console.log(` ${note}`);
1920
+ }
1888
1921
  process.exitCode = 1;
1889
1922
  }
1890
1923
  }
@@ -1913,7 +1946,7 @@ function printResult(result, { flags = {}, mode = null, boot = false } = {}) {
1913
1946
  }
1914
1947
  const tool = (result.results && result.results.management_tools && result.results.management_tools.command) || toolCommand(flags);
1915
1948
  const extra = resultExtras(result, tool);
1916
- const summary = renderFinalSummary({ verification: result.verification, e2e: result.e2e || [], extra, tool, mode: mode || result.mode });
1949
+ 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
1950
  console.log(summary.text);
1918
1951
  console.log(`current job: ${currentJobOf(result, flags)}`);
1919
1952
  // The full path is printed even when ~/.local/bin is already in PATH:
@@ -2336,7 +2369,7 @@ async function main() {
2336
2369
  console.error(' management (the `animastor` command in PATH):');
2337
2370
  console.error(' animastor start | stop | status | logs [-f] | doctor [--new-key] [--wait-job-ms N] [--force] | boot');
2338
2371
  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');
2372
+ 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
2373
  console.error(' --accept-node-deps-overrides consent: the node-deps overlay may replace a package another profile / ComfyUI core uses');
2341
2374
  console.error(' (also: monitor | reboot-worker | reboot-comfyui)');
2342
2375
  console.error(' (--state/--root/--worker-dir/--port override discovery)');
@@ -2361,7 +2394,7 @@ module.exports = {
2361
2394
  cmdUninstall, cmdStatus, cmdMonitor, cmdRebootWorker, cmdRebootComfyUI, resolveAndPlan,
2362
2395
  makeSecretProvider, resolveToolsDecision, resolveToolsDir, installOptions, runHostGates,
2363
2396
  PLATFORM_RUNTIME, printPlatformNotices, homeDir,
2364
- toolCommand, toolCommandPath, detectHubVersion, priorReusableDecisions, isBootRun,
2397
+ toolCommand, toolCommandPath, detectHubVersion, priorReusableDecisions, applicableDecisions, isBootRun,
2365
2398
  missingRequiredHostPackages, shouldWaitForPlatformComfy, platformComfyGate, platformComfyMissingResult,
2366
2399
  restartPlatformComfyDecision, platformNodeDepsGate, nodeDepsFailedResult, recordInstallerOption,
2367
2400
  cmdBoot, bootChildArgs, bootLogPath, startupScriptLine,
@@ -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
 
@@ -331,8 +332,8 @@ async function runInstallation(args) {
331
332
  // when they do not contradict the machine: an install-state that says
332
333
  // "managed / startComfyui=true" while the PLATFORM runs its own ComfyUI
333
334
  // 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;
335
+ let comfyOwner = options.comfyOwner || null;
336
+ let foreignComfy = comfyOwner && comfyOwner.owner === 'foreign' ? comfyOwner : null;
336
337
  if (!dryRun && comfyOwner) {
337
338
  for (const c of comfyOwner.conflicts || []) log.info(`install state corrected — ${c.message}`);
338
339
  if (st.mode !== mode) {
@@ -489,6 +490,24 @@ async function runInstallation(args) {
489
490
  try {
490
491
  save();
491
492
 
493
+ // 4.0a Worker Key preflight (0.2.13) — a revoked key kept in .env is
494
+ // found and replaced HERE, before hours of downloads, not at `start
495
+ // worker`. Without a terminal nothing is asked: the installation goes
496
+ // on, the worker is not started and the result names the fix.
497
+ const workerWanted = decisions.worker_setup === true || decisions.worker_setup === 'yes'
498
+ || !!(stepById(plan, 'worker-key') && (stepById(plan, 'worker-key').provided || decisions.worker_key_provided === true));
499
+ const hubTargets = hubPreflight.workerHubTargets(io, { workerDir, hubUrl, hubUrlExplicit: !!options.hubUrlExplicit });
500
+ let keyCheck = { status: 'skipped', reason: null, token: null, replaced: false };
501
+ if (workerWanted && workerDir) {
502
+ const typed = secretProvider && (options.replaceWorkerKey || !hubTargets.token) ? await secretProvider(hubPreflight.TOKEN_KEY) : null;
503
+ const token = typed || hubTargets.token;
504
+ if (token && log.registerSecret) log.registerSecret(token);
505
+ keyCheck = await hubPreflight.ensureWorkerKey(io, {
506
+ apiUrl: hubTargets.apiUrl, token, workerVersion: worker.readPkgVersion(io, workerDir),
507
+ ask: options.askWorkerKey || null, log,
508
+ });
509
+ }
510
+
492
511
  // 4.1 ComfyUI -----------------------------------------------------------
493
512
  const comfyStep = stepById(plan, 'comfyui-update');
494
513
  if (comfyStep && comfyStep.abort) {
@@ -681,22 +700,10 @@ async function runInstallation(args) {
681
700
  const nodesApproved = !runtimeFatal && nodesStep && nodesStep.action && nodesStep.decision === 'yes';
682
701
  if (!runtimeFatal && (nodesApproved || retryDeps.length > 0)) {
683
702
  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
- }
703
+ // A platform ComfyUI imports with ITS interpreter: pip into
704
+ // <root>/venv is useful only when that is the same Python (0.2.13).
705
+ const processPython = foreignComfy ? nodeDeps.pythonOfProcess(io, foreignComfy.pid).python : null;
706
+ const nodesPython = io.fs.existsSync(python) && (!foreignComfy || processPython === python) ? python : null;
700
707
  const approvedIds = ((nodesStep && nodesStep.missing) || []).map((x) => x.id);
701
708
  const repairOnlyIds = retryDeps.filter((id) => !approvedIds.includes(id));
702
709
  const effectiveStep = nodesApproved
@@ -709,12 +716,17 @@ async function runInstallation(args) {
709
716
  const nodeTorchSpec = pickTorchSpec(manifests, decisions, result.warnings, device);
710
717
  const r = await log.step('install custom nodes', () => withBusySync('Installing custom nodes', () => nodes.installCustomNodes(io, {
711
718
  root: comfyuiRoot, manifests, planStep: effectiveStep,
712
- python: io.fs.existsSync(python) ? python : null,
719
+ python: nodesPython,
713
720
  torchSpec: nodeTorchSpec ? nodeTorchSpec.spec : null,
714
721
  retryDeps, log,
715
722
  })));
716
723
  result.results.custom_nodes = r.ok ? r.value : [{ status: 'failed', reason: String(r.error && r.error.message) }];
717
724
  for (const item of result.results.custom_nodes) {
725
+ // Host build packages are asked for only when a source build failed.
726
+ if (item.pip_output && !result.remediation) {
727
+ result.remediation = prereq.buildToolsRemediation(io, { output: item.pip_output, python: nodesPython || 'python3', platformAdapter });
728
+ }
729
+ delete item.pip_output;
718
730
  // Only directories the installer actually created are ours.
719
731
  if (item.status === 'installed' && item.origin === 'installed' && item.directory) {
720
732
  state.addOwnedComponent(st, 'custom_nodes', { id: item.id, path: path.join(comfyuiRoot, 'custom_nodes', item.directory) });
@@ -754,8 +766,37 @@ async function runInstallation(args) {
754
766
  }
755
767
  }
756
768
 
769
+ // 4.3a A node installed just now brought its requirements.txt with it:
770
+ // the dependency gate of the platform's ComfyUI ran BEFORE the clone and
771
+ // could not see it, so it runs again (overlay install + restart, 0.2.13).
772
+ let nodeDepsGate = null;
773
+ const freshNodes = (result.results.custom_nodes || []).filter((x) => x.status === 'installed' && x.origin === 'installed');
774
+ if (!runtimeFatal && foreignComfy && freshNodes.length > 0 && options.platformNodeDeps) {
775
+ log.info(`checking the Python dependencies of the installed node(s): ${freshNodes.map((x) => x.directory).join(', ')}`);
776
+ nodeDepsGate = await options.platformNodeDeps(comfyOwner);
777
+ Object.assign(st.installer_options, nodeDepsGate.record);
778
+ for (const e of nodeDepsGate.ownedServices || []) state.addOwnedComponent(st, 'services', e);
779
+ result.results.node_deps_overrides = nodeDepsGate.overrides;
780
+ if (nodeDepsGate.instance && nodeDepsGate.instance.owner === 'foreign') {
781
+ comfyOwner = nodeDepsGate.instance;
782
+ foreignComfy = comfyOwner;
783
+ options.comfyOwner = comfyOwner;
784
+ if (st.comfy_owner) Object.assign(st.comfy_owner, { pid: comfyOwner.pid ?? null, url: comfyOwner.url || null });
785
+ if (foreignComfy.port) options.comfyPort = foreignComfy.port;
786
+ }
787
+ if (nodeDepsGate.failed) {
788
+ options.nodeClassesDeadline = null; // the cause is known: waiting cannot help
789
+ log.error(`custom-node dependencies: ${nodeDepsGate.reason}`);
790
+ }
791
+ save();
792
+ }
793
+
757
794
  // 4.4 Models ---------------------------------------------------------------
758
795
  const modelsStep = stepById(plan, 'models');
796
+ // Never silent (0.2.13): the plan lists these files as missing.
797
+ if (!runtimeFatal && modelsStep && modelsStep.skipped_by_user) {
798
+ log.warn(`model downloads skipped — declined (${modelsStep.missing.length} missing: ${modelsStep.missing.map((x) => x.label).join(', ')})`);
799
+ }
759
800
  if (!runtimeFatal && modelsStep && modelsStep.action && modelsStep.decision === 'yes') {
760
801
  const getHeader = downloader.makeHeaderProvider(process.env);
761
802
  const missingIds = (modelsStep.missing || []).map((x) => x.id);
@@ -1032,8 +1073,6 @@ async function runInstallation(args) {
1032
1073
  // reach .env on every run: otherwise an already-running worker keeps
1033
1074
  // its stale wiring forever.
1034
1075
  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
1076
  let tokenValue = null; // held in memory only; never stored on result/state
1038
1077
  let workerConfigChanged = false; // .env or bundle changed in THIS run → restart a running worker
1039
1078
  if (workerWanted) {
@@ -1072,6 +1111,15 @@ async function runInstallation(args) {
1072
1111
  tokenValue = fresh;
1073
1112
  }
1074
1113
  }
1114
+ if (keyCheck.status === 'rejected') {
1115
+ // a key Animastor refuses is never written (the next run asks again)
1116
+ delete values[hubPreflight.TOKEN_KEY];
1117
+ delete secretOverrides[hubPreflight.TOKEN_KEY];
1118
+ tokenValue = keyCheck.token; // memory only: the verification reports the failed registration
1119
+ } else if (keyCheck.replaced) {
1120
+ secretOverrides[hubPreflight.TOKEN_KEY] = keyCheck.token;
1121
+ tokenValue = keyCheck.token;
1122
+ }
1075
1123
  const cfg = await log.step('configure worker .env', async () => worker.configureEnv(io, {
1076
1124
  workerDir, manifest, values,
1077
1125
  overrides: decisions.apply_fixes !== false ? desired : {},
@@ -1170,7 +1218,17 @@ async function runInstallation(args) {
1170
1218
  let startedWorkerPid = null;
1171
1219
  let workerReady = null;
1172
1220
  let workerStart = null;
1173
- if (options.startWorker && workerDir && !runtimeFatal) {
1221
+ let hubProtocol = null;
1222
+ if (options.startWorker && workerDir && !runtimeFatal && keyCheck.status !== 'rejected') {
1223
+ hubProtocol = await hubPreflight.checkHubProtocol(io, {
1224
+ hubUrl: hubPreflight.workerHubTargets(io, { workerDir, hubUrl }).hubUrl, workerDir,
1225
+ });
1226
+ if (hubProtocol.status === 'ok') log.info(`hub protocol: compatible (worker ${hubProtocol.worker.join(', ')}, hub ${hubProtocol.hub.join(', ')})`);
1227
+ else if (hubProtocol.reason) log.warn(hubProtocol.reason);
1228
+ }
1229
+ const startBlocked = keyCheck.status === 'rejected' || !!(hubProtocol && hubProtocol.status === 'mismatch') || !!(nodeDepsGate && nodeDepsGate.failed);
1230
+ if (startBlocked && options.startWorker && workerDir && !runtimeFatal) log.warn('worker not started — see the result for the cause');
1231
+ if (options.startWorker && workerDir && !runtimeFatal && !startBlocked) {
1174
1232
  const r = await log.step('start worker', async () => {
1175
1233
  const bundleChanged = !!options.bundleRefreshedEarly || result.results.worker.some((x) => x.bundle && (x.bundle.files_installed || []).length > 0);
1176
1234
  // Installer 0.2.8: a running worker is restarted only when its
@@ -1290,7 +1348,7 @@ async function runInstallation(args) {
1290
1348
  comfyTried: (result.results.comfy_url && result.results.comfy_url.tried) || (foreignComfy && foreignComfy.url ? [foreignComfy.url] : []),
1291
1349
  platformComfy: !!foreignComfy,
1292
1350
  workerWanted: !!(options.startWorker && workerDir && !runtimeFatal),
1293
- workerStart, workerReady,
1351
+ workerStart, workerReady, keyCheck, hubProtocol, nodeDepsGate,
1294
1352
  tool: options.toolCommand || toolCommandFrom(result.results.management_tools),
1295
1353
  });
1296
1354
 
@@ -1435,7 +1493,7 @@ function toolCommandFrom(tools) {
1435
1493
  * prints exactly these (no "scroll up").
1436
1494
  * @returns {Promise<Array<{ id, ok: boolean|null, label, detail, fix }>>}
1437
1495
  */
1438
- async function endToEndChecks(io, { mode, comfyUrl, comfyPort, hubUrl, workerWanted, workerStart, workerReady, tool = 'animastor', comfyTried = [], platformComfy = false }) {
1496
+ async function endToEndChecks(io, { mode, comfyUrl, comfyPort, hubUrl, workerWanted, workerStart, workerReady, keyCheck = null, hubProtocol = null, nodeDepsGate = null, tool = 'animastor', comfyTried = [], platformComfy = false }) {
1439
1497
  const checks = [];
1440
1498
  const stats = comfyUrl ? await comfyui.systemStats(io, comfyUrl) : null;
1441
1499
  // Addresses in the result are always FULL (with the notebook prefix):
@@ -1456,12 +1514,38 @@ async function endToEndChecks(io, { mode, comfyUrl, comfyPort, hubUrl, workerWan
1456
1514
  ? `start your ComfyUI so that ${prefixed} answers, then run: ${tool} doctor`
1457
1515
  : `start your ComfyUI on port ${comfyPort || 8188}, then run: ${tool} doctor`,
1458
1516
  });
1517
+ // 0.2.13: the key and the protocol are matters of the HUB. Both used to be
1518
+ // reported as "Worker → ComfyUI: Worker Key rejected".
1519
+ const r = workerReady || {};
1520
+ const newKeyFix = `create a new Worker Key in Animastor → Settings → Workers, then run: ${tool} doctor --new-key`;
1521
+ const keyRejected = !!(keyCheck && keyCheck.status === 'rejected');
1522
+ const mismatch = !!(hubProtocol && hubProtocol.status === 'mismatch');
1523
+ const blocked = [];
1524
+ if (keyRejected || r.auth_failed) {
1525
+ const detail = (keyRejected ? keyCheck.reason : r.reason) || 'the Worker Key was rejected';
1526
+ checks.push({ id: 'hub-auth', ok: false, label: 'Worker → Hub (Worker Key)', detail: detail.replace(/\s+/g, ' '), fix: newKeyFix });
1527
+ blocked.push('the hub does not accept its Worker Key');
1528
+ }
1529
+ if (mismatch) {
1530
+ checks.push({ id: 'hub-protocol', ok: false, label: 'Worker → Hub (protocol)', detail: hubProtocol.reason, fix: hubProtocol.fix });
1531
+ blocked.push('the hub does not serve its job protocol');
1532
+ }
1533
+ if (nodeDepsGate && nodeDepsGate.failed) {
1534
+ checks.push({ id: 'node-deps', ok: false, label: 'Custom-node dependencies', detail: nodeDepsGate.reason, fix: nodeDepsGate.fix || null });
1535
+ blocked.push('the ComfyUI has no node classes for this profile');
1536
+ }
1537
+ if (workerWanted && blocked.length > 0) {
1538
+ checks.push(r.comfy_ready
1539
+ ? { id: 'worker', ok: true, label: 'Worker → ComfyUI', detail: '"ComfyUI ready" in the worker log', fix: null }
1540
+ : { id: 'worker', ok: null, label: 'Worker → ComfyUI', detail: `not checked — the worker does not run: ${blocked.join('; ')}`, fix: null });
1541
+ checks.push({ id: 'heartbeat', ok: null, label: 'Hub heartbeat (Online)', detail: 'not checked — the worker does not run', fix: null });
1542
+ return checks;
1543
+ }
1459
1544
  if (!workerWanted) {
1460
1545
  checks.push({ id: 'worker', ok: null, label: 'Worker → ComfyUI', detail: 'worker start skipped (--no-start-worker)', fix: `${tool} start` });
1461
1546
  checks.push({ id: 'heartbeat', ok: null, label: 'Hub heartbeat (Online)', detail: 'not checked — worker not started', fix: `${tool} start` });
1462
1547
  return checks;
1463
1548
  }
1464
- const newKeyFix = `create a new Worker Key in Animastor → Settings → Workers, then run: ${tool} doctor --new-key`;
1465
1549
  if (workerStart && workerStart.deferred) {
1466
1550
  // Installer 0.2.8: the worker keeps running (and serving) on its old
1467
1551
  // configuration; the needed restart was not done — FAILED, exit ≠ 0.
@@ -1475,7 +1559,6 @@ async function endToEndChecks(io, { mode, comfyUrl, comfyPort, hubUrl, workerWan
1475
1559
  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
1560
  return checks;
1477
1561
  }
1478
- const r = workerReady || {};
1479
1562
  // A running worker left as is (installer 0.2.8) is not restarted by
1480
1563
  // another doctor run — the fix that restarts it is reboot-worker.
1481
1564
  const rerun = workerStart && workerStart.action === 'left' ? `${tool} reboot-worker` : `${tool} doctor`;
@@ -1485,18 +1568,24 @@ async function endToEndChecks(io, { mode, comfyUrl, comfyPort, hubUrl, workerWan
1485
1568
  const reason = (r.reason || (workerStart && workerStart.reason) || 'worker did not start').replace(/\s+/g, ' ');
1486
1569
  checks.push({
1487
1570
  id: 'worker', ok: false, label: 'Worker → ComfyUI', detail: reason,
1488
- fix: r.auth_failed ? newKeyFix : rerun,
1571
+ fix: rerun,
1489
1572
  });
1490
1573
  }
1491
1574
  if (r.heartbeat) {
1492
1575
  checks.push({ id: 'heartbeat', ok: true, label: 'Hub heartbeat (Online)', detail: hubUrl || null, fix: null });
1493
1576
  } 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 });
1577
+ checks.push({ id: 'heartbeat', ok: false, label: 'Hub heartbeat (Online)', detail: 'not reached — the worker sends heartbeats only after it reached ComfyUI', fix: rerun });
1578
+ } else if (r.protocol_mismatch) {
1579
+ checks.push({
1580
+ id: 'heartbeat', ok: false, label: 'Worker → Hub (protocol)',
1581
+ detail: 'the hub has no route for the job protocol of this worker bundle (HTTP 404) — the Worker Key is not the cause',
1582
+ 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',
1583
+ });
1495
1584
  } else {
1496
1585
  checks.push({
1497
1586
  id: 'heartbeat', ok: false, label: 'Hub heartbeat (Online)',
1498
1587
  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}`,
1588
+ fix: `check that this machine reaches ${hubUrl} (curl -fsS ${hubUrl}/health), then run: ${rerun}`,
1500
1589
  });
1501
1590
  }
1502
1591
  return checks;
@@ -1553,7 +1642,32 @@ async function runVerification({ io, manifests, roots, options, log, crypto, tok
1553
1642
  // re-checked until the end of the wait window — not FAILED at once.
1554
1643
  const deadline = Number(options.nodeClassesDeadline) || 0;
1555
1644
  const pause = options.sleep || ((ms) => new Promise((r) => setTimeout(r, ms)));
1645
+ // Installer 0.2.5: say WHY (missing packages / IMPORT FAILED /
1646
+ // restart needed) — "run doctor" alone looped on the live node.
1647
+ const ownerInfo = options.comfyOwner || null;
1648
+ const diagnose = async (missing) => {
1649
+ const pid = ownerInfo && ownerInfo.pid ? ownerInfo.pid : null;
1650
+ const py = pid ? nodeDeps.pythonOfProcess(io, pid).python : null;
1651
+ let extraPaths = [];
1652
+ if (py && workerDir && ownerInfo && ownerInfo.owner === 'foreign') {
1653
+ const plan = pydeps.planPersistence(io, { python: py, root: comfyuiRoot, base: pydeps.overlayBase(workerDir), create: false });
1654
+ if (plan.kind === 'overlay' && plan.sitePackages && io.fs.existsSync(plan.sitePackages)) extraPaths = [plan.sitePackages];
1655
+ }
1656
+ const logFiles = [
1657
+ workerDir ? path.join(path.dirname(path.resolve(workerDir)), 'logs', 'comfyui-restart.log') : null,
1658
+ comfyuiRoot ? path.join(comfyuiRoot, 'comfyui-installer.log') : null,
1659
+ ].filter(Boolean);
1660
+ return nodeDeps.diagnoseMissingClasses(io, {
1661
+ missingClasses: missing, manifests, root: comfyuiRoot, url: baseUrl, pid, python: py, extraPaths, logFiles,
1662
+ });
1663
+ };
1664
+ let diag = null;
1556
1665
  if (missingClasses.length > 0 && deadline > io.now()) {
1666
+ // Missing packages never appear by waiting (0.2.13: 117 s lost).
1667
+ try { diag = await diagnose(missingClasses); } catch (_) { diag = null; }
1668
+ if (diag && diag.kind !== 'deps-missing') diag = null;
1669
+ }
1670
+ if (missingClasses.length > 0 && deadline > io.now() && !diag) {
1557
1671
  log.info(`node classes not registered yet (${missingClasses.join(', ')}) — re-checking for up to ${Math.round((deadline - io.now()) / 1000)} s`);
1558
1672
  while (missingClasses.length > 0 && io.now() < deadline) {
1559
1673
  await pause(Math.min(options.pollIntervalMs || 3000, Math.max(1, deadline - io.now())));
@@ -1564,24 +1678,8 @@ async function runVerification({ io, manifests, roots, options, log, crypto, tok
1564
1678
  }
1565
1679
  if (missingClasses.length > 0) {
1566
1680
  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
1681
  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
- });
1682
+ diag = diag || await diagnose(missingClasses);
1585
1683
  live.comfyui.missing_node_classes_cause = {
1586
1684
  kind: diag.kind, detail: diag.detail, log_source: diag.log_source,
1587
1685
  owner: ownerInfo && ownerInfo.owner === 'foreign' ? 'foreign' : 'managed',
@@ -1628,6 +1726,7 @@ async function runVerification({ io, manifests, roots, options, log, crypto, tok
1628
1726
  const reg = await worker.verifyRegistration(io, { hubUrl, token, expectedType });
1629
1727
  emit('registration', { registered: reg.registered, worker_id: reg.worker_id || null, worker_type: reg.worker_type || null, reason: reg.reason || null });
1630
1728
  live.worker = { process_alive: null, registered: reg.registered === true };
1729
+ if (!reg.registered) live.registration_cause = { kind: [401, 403].includes(reg.status_code) ? 'key' : 'hub', detail: reg.reason };
1631
1730
  live.hub = { connection: reg.reason ? reg.reason.indexOf('unreachable') === -1 : true, registration: reg.registered === true };
1632
1731
  if (!reg.registered) {
1633
1732
  log.warn('Installation completed locally, but Worker registration failed. The installed environment is intact — fix the credential/network and re-run `verify`.');
@@ -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 };
@@ -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,
@@ -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
  }