@animastor/installer 0.2.4 → 0.2.9

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.
@@ -239,7 +239,11 @@ function configureEnv(io, { workerDir, manifest, values = {}, overrides = {}, se
239
239
  if (text && !text.endsWith('\n')) text += '\n';
240
240
  text += additions.join('\n') + '\n';
241
241
  }
242
- io.fs.writeFileSync(envPath, text);
242
+ // Installer 0.2.8: an unchanged .env is NOT rewritten. Its mtime is the
243
+ // "configuration changed after the worker started" marker
244
+ // (workerConfigNewer) — rewriting identical content made every doctor
245
+ // run restart a running (even busy) worker (04.11, 13:55/13:58 UTC).
246
+ if (envCreated || text !== existingText) io.fs.writeFileSync(envPath, text);
243
247
  io.fs.chmodSync(envPath, 0o600);
244
248
 
245
249
  if (log) log.info(`.env configured: ${preserved.length} key(s) preserved, ${additions.length} added, ${changed.length} updated${changed.length ? ` (${changed.join(', ')})` : ''}, ${missingAfter.length} still missing`);
@@ -414,22 +418,61 @@ function findRunningWorkerPid(io, workerDir, opts = {}) {
414
418
  */
415
419
  function workerEnvIsNewer(io, { workerDir, pid, platformAdapter = null }) {
416
420
  try {
417
- const adapter = platformAdapter || adapterOf({});
418
421
  const envM = io.fs.statSync(path.join(workerDir, '.env')).mtimeMs;
419
- // Most reliable marker: logs/worker.pid written at start (by this
420
- // installer and by start-worker.sh) — its mtime IS the start time.
422
+ const procM = workerProcessStartMs(io, { workerDir, pid, platformAdapter });
423
+ if (procM == null) return false;
424
+ return envM > procM + 1000; // 1s tolerance for same-second writes
425
+ } catch (_) {
426
+ return false;
427
+ }
428
+ }
429
+
430
+ /**
431
+ * Start time of the running worker `pid` (ms) or null when unknown.
432
+ * Most reliable marker: logs/worker.pid written at start (by this installer
433
+ * and by start-worker.sh) — its mtime IS the start time; then the platform
434
+ * adapter (/proc/<pid> on Linux, the pid marker on Windows).
435
+ */
436
+ function workerProcessStartMs(io, { workerDir, pid, platformAdapter = null }) {
437
+ try {
438
+ const adapter = platformAdapter || adapterOf({});
421
439
  let procM = pidFileStartMs(io, workerDir, pid);
422
440
  if (procM == null) procM = adapter.processStartMs(io, pid);
423
441
  if (procM == null && typeof adapter.workerStartMarkerMs === 'function') {
424
442
  procM = adapter.workerStartMarkerMs(io, workerDir);
425
443
  }
426
- if (procM == null) return false;
427
- return envM > procM + 1000; // 1s tolerance for same-second writes
444
+ return procM == null ? null : procM;
428
445
  } catch (_) {
429
- return false;
446
+ return null;
430
447
  }
431
448
  }
432
449
 
450
+ /** Files whose change requires a worker restart: .env and the bundle (installer 0.2.8). */
451
+ const WORKER_CONFIG_FILES = Object.freeze(['.env', 'package.json', 'worker.cjs', 'worker-env.cjs',
452
+ 'job-protocol-v2.cjs', 'worker-cleanup.cjs', 'worker-cleanup-journal.cjs']);
453
+
454
+ /**
455
+ * Configuration files (.env, bundle files) modified AFTER the worker `pid`
456
+ * started — the running process holds the old configuration (env and code
457
+ * are fixed at process start). Persistent across runs: a restart deferred
458
+ * because the worker was busy is still required on the next run. Unknown
459
+ * start time → [] (never restart on a guess).
460
+ * @returns {string[]} changed file names
461
+ */
462
+ function workerConfigNewer(io, { workerDir, pid, platformAdapter = null, files = WORKER_CONFIG_FILES }) {
463
+ const procM = workerProcessStartMs(io, { workerDir, pid, platformAdapter });
464
+ if (procM == null) return [];
465
+ const out = [];
466
+ for (const f of files) {
467
+ try {
468
+ const p = path.join(workerDir, f);
469
+ if (!io.fs.existsSync(p)) continue;
470
+ if (io.fs.statSync(p).mtimeMs > procM + 1000) out.push(f);
471
+ } catch (_) { /* unreadable → not counted */ }
472
+ }
473
+ return out;
474
+ }
475
+
433
476
  /** Default worker log: <install base>/logs/worker.log (same file start-worker.sh uses). */
434
477
  function workerLogPath(workerDir) {
435
478
  return path.join(path.dirname(workerDir), 'logs', 'worker.log');
@@ -507,6 +550,18 @@ function startWorker(io, { workerDir, nodeBin = null, logFile = null, graceMs =
507
550
  if (existing && !forceRestart && !workerEnvIsNewer(io, { workerDir, pid: existing, platformAdapter: adapter })) {
508
551
  return { started: true, already_running: true, pid: existing, alive: true, reason: null, logFile: log, logOffset: null };
509
552
  }
553
+ if (existing && !forceRestart) {
554
+ // Installer 0.2.8: a stale-config restart never kills a task in
555
+ // progress (`animastor start` path; doctor/install decide in
556
+ // ensureWorker, which waits for the task).
557
+ const act = readWorkerActivity(io, { workerDir, pid: existing, logFile: log });
558
+ if (act.known && act.current_job_id) {
559
+ return {
560
+ started: true, already_running: true, pid: existing, alive: true, reason: null, logFile: log, logOffset: null,
561
+ restart_pending: ['.env'], busy_job: act.current_job_id,
562
+ };
563
+ }
564
+ }
510
565
  if (existing) {
511
566
  // .env changed after this worker started — it is running on the OLD
512
567
  // configuration (its env is fixed at process start). Restart it so
@@ -577,6 +632,98 @@ function scanWorkerLog(text) {
577
632
  };
578
633
  }
579
634
 
635
+ // ── Worker activity (installer 0.2.8) ─────────────────────────────────────────
636
+ // The hub's heartbeat record (current_job_id) lives in the hub's Redis and is
637
+ // not readable from the node; the worker's OWN log carries the same facts:
638
+ // "[ts] [info] Task <job_id> (type=…" — a task was taken
639
+ // "[ts] [info] Done <job_id>" — result delivered
640
+ // "[ts] [error] Failed <job_id>" — task failed (error sent)
641
+ // "[ts] [error] Rejecting incompatible task…" — the taken task was refused
642
+ // Only the output of the CURRENT process counts (after its last
643
+ // "Worker <type> started"). "Hub heartbeat accepted" is logged on the first
644
+ // accepted beacon and again after every recovery; every failed beacon logs
645
+ // "Beacon failed" — so "heartbeat fresh" = the latest beacon marker of this
646
+ // process is an accepted one.
647
+ const TASK_START_RE = /\] Task (\S+) \(type=/;
648
+ const TASK_END_RE = /\] (?:Done|Failed) (\S+)\s*$/;
649
+ const TASK_REJECT_RE = /\] Rejecting incompatible task/;
650
+ const WORKER_LOG_TAIL_BYTES = 4 * 1024 * 1024;
651
+
652
+ /**
653
+ * Pure: classify the worker log (text of one or more runs).
654
+ * @returns {{ started: boolean, current_job_id: string|null, last_job_id: string|null,
655
+ * comfy_ready: boolean, heartbeat: boolean, healthy: boolean, last_beacon_error: string|null }}
656
+ */
657
+ function parseWorkerActivity(text) {
658
+ const all = String(text || '').split('\n');
659
+ let start = -1;
660
+ all.forEach((l, i) => { if (/\] Worker \S+ started/.test(l)) start = i; });
661
+ const lines = start >= 0 ? all.slice(start) : all;
662
+ let current = null;
663
+ let last = null;
664
+ for (const l of lines) {
665
+ let m = TASK_START_RE.exec(l);
666
+ if (m) { current = m[1]; last = m[1]; continue; }
667
+ m = TASK_END_RE.exec(l);
668
+ if (m) { if (current === m[1]) current = null; continue; }
669
+ if (TASK_REJECT_RE.test(l)) current = null;
670
+ }
671
+ const scan = scanWorkerLog(lines.join('\n'));
672
+ return {
673
+ started: start >= 0,
674
+ current_job_id: current,
675
+ last_job_id: last,
676
+ comfy_ready: scan.comfy_ready,
677
+ heartbeat: scan.heartbeat,
678
+ healthy: start >= 0 && scan.comfy_ready && scan.heartbeat && !scan.crashed && !scan.auth_failed,
679
+ last_beacon_error: scan.last_beacon_error,
680
+ };
681
+ }
682
+
683
+ /**
684
+ * Activity of the running worker `pid` from its log (tail of at most
685
+ * WORKER_LOG_TAIL_BYTES). known=false when there is no log, or the log was
686
+ * last written BEFORE this process started (it is some other process's log —
687
+ * busy/idle cannot be told).
688
+ * @returns {{ known: boolean, reason: string|null, current_job_id, last_job_id, comfy_ready, heartbeat, healthy, last_beacon_error, log_file }}
689
+ */
690
+ function readWorkerActivity(io, { workerDir, pid = null, logFile = null, tailBytes = WORKER_LOG_TAIL_BYTES }) {
691
+ const log = logFile || workerLogPath(workerDir);
692
+ const unknown = (reason) => ({
693
+ known: false, reason, current_job_id: null, last_job_id: null, comfy_ready: false, heartbeat: false,
694
+ healthy: false, last_beacon_error: null, log_file: log,
695
+ });
696
+ let text;
697
+ try {
698
+ if (!io.fs.existsSync(log)) return unknown(`no worker log at ${log}`);
699
+ text = String(io.fs.readFileSync(log, 'utf8'));
700
+ } catch (err) {
701
+ return unknown(`worker log ${log} unreadable: ${err.message}`);
702
+ }
703
+ if (pid) {
704
+ // Only the pid file is a precise start marker here (/proc/<pid> mtime
705
+ // on Linux is the procfs inode time, not the start time).
706
+ const procM = pidFileStartMs(io, workerDir, pid);
707
+ let logM = null;
708
+ try { logM = io.fs.statSync(log).mtimeMs; } catch (_) { logM = null; }
709
+ if (procM != null && typeof logM === 'number' && logM + 1000 < procM) {
710
+ return unknown(`worker log ${log} was not written by the running worker (pid ${pid})`);
711
+ }
712
+ }
713
+ if (text.length > tailBytes) text = text.slice(text.length - tailBytes);
714
+ const a = parseWorkerActivity(text);
715
+ return { known: true, reason: null, ...a, log_file: log };
716
+ }
717
+
718
+ /** "none" | "<job_id>" | "unknown" for the `current job:` line of doctor/status. */
719
+ function currentJobLabel(io, { workerDir, pid = undefined, platformAdapter = null, logFile = null }) {
720
+ const p = pid === undefined ? findRunningWorkerPid(io, workerDir, { platformAdapter }) : pid;
721
+ if (!p) return 'none';
722
+ const a = readWorkerActivity(io, { workerDir, pid: p, logFile });
723
+ if (!a.known) return 'unknown';
724
+ return a.current_job_id || 'none';
725
+ }
726
+
580
727
  function readLogFrom(io, logFile, offset) {
581
728
  try {
582
729
  const text = String(io.fs.readFileSync(logFile, 'utf8'));
@@ -735,6 +882,199 @@ async function restartManagedWorker(io, { workerDir, log = null, stopTimeoutMs =
735
882
  return { restarted: true, previously_running: previouslyRunning, pid: start.pid, alive: start.alive, reason: start.reason };
736
883
  }
737
884
 
885
+ // ── ensureWorker (installer 0.2.8) ──────────────────────────────────────────
886
+ // install/doctor/boot no longer restart a running worker by default
887
+ // (04.11: doctor restarted the audio/image workers at 13:55:15 and 13:58:52,
888
+ // between tasks only by chance — a result in flight would have been lost).
889
+ //
890
+ // not running → start
891
+ // running, configuration unchanged → left as is
892
+ // running, .env/bundle changed:
893
+ // boot (doctor --yes, no TTY) → left as is, restart pending (warn)
894
+ // --force → restart now
895
+ // idle → restart
896
+ // busy (a task in progress) → wait up to waitJobMs for the task
897
+ // to finish, then restart; still
898
+ // busy → DEFERRED (FAILED, exit ≠ 0)
899
+ // busy state unknown (no log of this
900
+ // process) → DEFERRED (FAILED; --force restarts)
901
+ const DEFAULT_WAIT_JOB_MS = 600000;
902
+
903
+ /**
904
+ * Pure decision for a running worker.
905
+ * @returns {{ action: 'start'|'leave'|'restart'|'wait'|'defer', reasons: string[] }}
906
+ */
907
+ function decideWorkerAction({ pid = null, reasons = [], activity = null, force = false, boot = false }) {
908
+ if (!pid) return { action: 'start', reasons: [] };
909
+ if (reasons.length === 0) return { action: 'leave', reasons: [] };
910
+ if (force) return { action: 'restart', reasons };
911
+ if (boot) return { action: 'leave', reasons };
912
+ if (!activity || !activity.known) return { action: 'defer', reasons };
913
+ if (activity.current_job_id) return { action: 'wait', reasons };
914
+ return { action: 'restart', reasons };
915
+ }
916
+
917
+ /**
918
+ * Bring the worker of this installation up without ever killing a task in
919
+ * progress (see the table above). Returns the startWorker() shape plus
920
+ * { action, restart_reasons, current_job, busy_job, deferred, restart_pending }.
921
+ * @param {object} o
922
+ * @param {string[]} [o.configChanged] what THIS run changed (".env", "worker bundle 2.2.2 → 2.2.3")
923
+ */
924
+ async function ensureWorker(io, {
925
+ workerDir, nodeBin = null, graceMs = 3000, platformAdapter = null, logFile = null,
926
+ configChanged = [], force = false, boot = false, waitJobMs = DEFAULT_WAIT_JOB_MS,
927
+ pollMs = 5000, progressMs = 30000, sleep = null, log = null, startFn = startWorker, tool = 'animastor',
928
+ }) {
929
+ const adapter = platformAdapter || adapterOf({});
930
+ const lf = logFile || workerLogPath(workerDir);
931
+ const now = () => (io.now ? io.now() : Date.now());
932
+ const wait = sleep || ((ms) => new Promise((r) => setTimeout(r, ms)));
933
+ const info = (m) => { if (log) log.info(m); };
934
+ const warn = (m) => { if (log) log.warn(m); };
935
+ const start = (forceRestart) => startFn(io, { workerDir, nodeBin, graceMs, platformAdapter: adapter, logFile: lf, forceRestart });
936
+
937
+ let pid = findRunningWorkerPid(io, workerDir, { platformAdapter: adapter });
938
+ if (!pid) {
939
+ const res = start(false);
940
+ return { ...res, action: 'started', restart_reasons: [], current_job: 'none' };
941
+ }
942
+ // What this run changed explains itself; otherwise the persistent marker
943
+ // (files newer than the process — e.g. a restart deferred by an earlier run).
944
+ const reasons = (configChanged || []).length > 0
945
+ ? Array.from(new Set(configChanged))
946
+ : workerConfigNewer(io, { workerDir, pid, platformAdapter: adapter }).map((f) => `${f} changed after the worker started`);
947
+ let activity = readWorkerActivity(io, { workerDir, pid, logFile: lf });
948
+ const decision = decideWorkerAction({ pid, reasons, activity, force, boot });
949
+ const jobOf = (a) => (a.known ? (a.current_job_id || 'none') : 'unknown');
950
+ const left = (extra = {}) => ({
951
+ started: true, already_running: true, pid, alive: true, reason: null, logFile: lf, logOffset: null,
952
+ action: 'left', restart_reasons: reasons, current_job: jobOf(activity), ...extra,
953
+ });
954
+ const deferred = (why) => ({
955
+ started: false, already_running: true, pid, alive: true, deferred: true, reason: why, logFile: lf, logOffset: null,
956
+ action: 'deferred', restart_reasons: reasons, current_job: jobOf(activity), busy_job: activity.current_job_id || null,
957
+ });
958
+
959
+ if (decision.action === 'leave' && reasons.length === 0) {
960
+ const health = activity.known && !activity.healthy
961
+ ? ` — ${activity.comfy_ready ? (activity.last_beacon_error ? `last beacon failed: ${activity.last_beacon_error}` : 'no heartbeat accepted yet') : 'it has not reached ComfyUI yet'}`
962
+ : '';
963
+ info(`worker already running (pid ${pid}), left as is${health}`);
964
+ return left();
965
+ }
966
+ if (decision.action === 'leave') {
967
+ warn(`worker already running (pid ${pid}), left as is — restart pending (${reasons.join('; ')}); the boot path never restarts a running worker: run \`${tool} doctor\``);
968
+ return left({ restart_pending: reasons });
969
+ }
970
+ if (decision.action === 'defer') {
971
+ const why = `cannot tell whether the worker (pid ${pid}) is busy (${activity.reason}) — restart for ${reasons.join('; ')} deferred; to restart anyway: ${tool} doctor --force`;
972
+ warn(why);
973
+ return deferred(why);
974
+ }
975
+ if (decision.action === 'wait') {
976
+ const deadline = now() + Math.max(0, Number(waitJobMs) || 0);
977
+ let nextProgress = now();
978
+ while (activity.known && activity.current_job_id && now() < deadline) {
979
+ if (now() >= nextProgress) {
980
+ info(`worker is busy with ${activity.current_job_id} (pid ${pid}) — waiting up to ${Math.round((deadline - now()) / 1000)} s for the task to finish before the restart (${reasons.join('; ')})`);
981
+ nextProgress = now() + progressMs;
982
+ }
983
+ await wait(Math.min(pollMs, Math.max(1, deadline - now())));
984
+ const still = findRunningWorkerPid(io, workerDir, { platformAdapter: adapter });
985
+ if (still !== pid) { pid = still; break; }
986
+ activity = readWorkerActivity(io, { workerDir, pid, logFile: lf });
987
+ }
988
+ if (!pid) {
989
+ info('the worker exited while waiting — starting it');
990
+ const res = start(false);
991
+ return { ...res, action: 'started', restart_reasons: reasons, current_job: 'none' };
992
+ }
993
+ if (!activity.known) {
994
+ const why = `cannot tell whether the worker (pid ${pid}) is busy (${activity.reason}) — restart for ${reasons.join('; ')} deferred; to restart anyway: ${tool} doctor --force`;
995
+ warn(why);
996
+ return deferred(why);
997
+ }
998
+ if (activity.current_job_id) {
999
+ const why = `worker is busy with ${activity.current_job_id} (pid ${pid}) — restart deferred (waited ${Math.round((Number(waitJobMs) || 0) / 1000)} s; needed for: ${reasons.join('; ')}); re-run \`${tool} doctor\` when the task finishes, or \`${tool} doctor --force\` to restart now (the task's result is lost)`;
1000
+ warn(why);
1001
+ return deferred(why);
1002
+ }
1003
+ info(`the worker (pid ${pid}) finished ${activity.last_job_id || 'its task'}`);
1004
+ }
1005
+ // restart: idle (or --force)
1006
+ if (force && activity.current_job_id) warn(`--force: restarting the worker (pid ${pid}) while it is busy with ${activity.current_job_id} — the task's result is lost`);
1007
+ info(`restarting the worker (pid ${pid}): ${reasons.join('; ')}`);
1008
+ const res = start(true);
1009
+ return { ...res, action: 'restarted', restarted_from: pid, restart_reasons: reasons, current_job: 'none' };
1010
+ }
1011
+
1012
+ // ── node-classes.json (installer 0.2.7, worker bundle >= 2.2.2) ─────────────
1013
+ // GPU E2E 2026-11-02: a worker took tasks from a ComfyUI without its
1014
+ // profile's nodes. Bundle 2.2.2 asks for tasks only after ComfyUI's
1015
+ // /object_info lists every class of this file; without the file it keeps the
1016
+ // old behaviour (ComfyUI API only) and logs one warning. The installer writes
1017
+ // it from the manifests' `provides_classes` (required dependencies only) on a
1018
+ // fresh install, on a bundle update and on every doctor/boot run — so a node
1019
+ // installed by an older installer gets it on its next doctor/boot.
1020
+ //
1021
+ // { "generated_by": "animastor-installer <v>",
1022
+ // "profiles": { "audio/qwen-tts": ["Qwen3TTSLoader", …] } }
1023
+ const NODE_CLASSES_FILE = 'node-classes.json';
1024
+
1025
+ /** {profileId: [classes]} of the given manifests (required deps only, sorted, unique). */
1026
+ function nodeClassesOfManifests(manifests) {
1027
+ const profiles = {};
1028
+ for (const m of manifests || []) {
1029
+ const id = m && m.profile && m.profile.id;
1030
+ if (!id) continue;
1031
+ const set = new Set(profiles[id] || []);
1032
+ for (const dep of m.dependencies || []) {
1033
+ if (dep && dep.requirement && dep.requirement !== 'required') continue;
1034
+ for (const cls of (dep && dep.provides_classes) || []) {
1035
+ if (typeof cls === 'string' && cls.trim()) set.add(cls.trim());
1036
+ }
1037
+ }
1038
+ profiles[id] = Array.from(set).sort();
1039
+ }
1040
+ return profiles;
1041
+ }
1042
+
1043
+ /**
1044
+ * Write <workerDir>/node-classes.json for the profiles of this run. Only when
1045
+ * a worker bundle is installed there (worker.cjs present). Atomic (temp +
1046
+ * rename); an identical file is left untouched.
1047
+ * @returns {{ status: 'written'|'current'|'absent'|'skipped'|'failed', path?: string, profiles?: object, reason?: string }}
1048
+ */
1049
+ function writeNodeClasses(io, { workerDir, manifests, log = null, version = null }) {
1050
+ if (!workerDir || !io.fs.existsSync(path.join(workerDir, 'worker.cjs'))) return { status: 'absent' };
1051
+ const profiles = nodeClassesOfManifests(manifests);
1052
+ if (Object.keys(profiles).length === 0) return { status: 'skipped', reason: 'no profile manifests' };
1053
+ const file = path.join(workerDir, NODE_CLASSES_FILE);
1054
+ let v = version;
1055
+ if (!v) { try { v = require('../../../package.json').version || null; } catch (_) { v = null; } }
1056
+ const doc = { generated_by: `animastor-installer${v ? ` ${v}` : ''}`, profiles };
1057
+ const text = JSON.stringify(doc, null, 2) + '\n';
1058
+ try {
1059
+ if (io.fs.existsSync(file)) {
1060
+ let current = null;
1061
+ try { current = JSON.parse(String(io.fs.readFileSync(file, 'utf8'))); } catch (_) { current = null; }
1062
+ if (current && JSON.stringify(current.profiles || null) === JSON.stringify(profiles)) {
1063
+ return { status: 'current', path: file, profiles };
1064
+ }
1065
+ }
1066
+ const tmp = `${file}.tmp-${process.pid}`;
1067
+ io.fs.writeFileSync(tmp, text);
1068
+ io.fs.renameSync(tmp, file);
1069
+ const n = Object.values(profiles).reduce((a, l) => a + l.length, 0);
1070
+ if (log) log.info(`${NODE_CLASSES_FILE} written: ${Object.keys(profiles).join(', ')} (${n} node class(es)) — the worker takes tasks only when ComfyUI lists them`);
1071
+ return { status: 'written', path: file, profiles };
1072
+ } catch (err) {
1073
+ if (log) log.warn(`${NODE_CLASSES_FILE} could not be written: ${err.message} — the worker falls back to the ComfyUI-API-only readiness`);
1074
+ return { status: 'failed', path: file, reason: err.message };
1075
+ }
1076
+ }
1077
+
738
1078
  module.exports = {
739
1079
  installWorkerBundle,
740
1080
  ensureWorkerDependencies,
@@ -754,9 +1094,21 @@ module.exports = {
754
1094
  restartManagedWorker,
755
1095
  findRunningWorkerPid,
756
1096
  workerEnvIsNewer,
1097
+ workerProcessStartMs,
1098
+ workerConfigNewer,
1099
+ WORKER_CONFIG_FILES,
1100
+ parseWorkerActivity,
1101
+ readWorkerActivity,
1102
+ currentJobLabel,
1103
+ decideWorkerAction,
1104
+ ensureWorker,
1105
+ DEFAULT_WAIT_JOB_MS,
757
1106
  configureEnv,
758
1107
  apiBaseFromHubUrl,
759
1108
  verifyRegistration,
760
1109
  checkWorkerCanStart,
761
1110
  renderEnvLines,
1111
+ NODE_CLASSES_FILE,
1112
+ nodeClassesOfManifests,
1113
+ writeNodeClasses,
762
1114
  };
@@ -183,7 +183,11 @@ async function collectStatus(io, targets, opts = {}) {
183
183
  } catch (_) { /* queue is optional */ }
184
184
  }
185
185
  return {
186
- worker: { running: !!workerPid, pid: workerPid || null },
186
+ // current job (installer 0.2.8): the running worker's task, from its own log.
187
+ worker: {
188
+ running: !!workerPid, pid: workerPid || null,
189
+ current_job: workerPid && targets.workerDir ? workerMod.currentJobLabel(io, { workerDir: targets.workerDir, pid: workerPid }) : 'none',
190
+ },
187
191
  comfyui: {
188
192
  running: comfyPids.length > 0, root_present: comfyRootPresent, port, pids: comfyPids, external, url: baseUrl,
189
193
  started_by: startedBy, foreign_pid: foreign ? foreign.pid : null,
@@ -222,6 +226,7 @@ function renderStatus(snapshot) {
222
226
  } else {
223
227
  lines.push('Queue: — (API unreachable)');
224
228
  }
229
+ lines.push(`current job: ${snapshot.worker.current_job || 'none'}`);
225
230
  if (snapshot.hub) {
226
231
  lines.push(`Hub: ${snapshot.hub.heartbeat ? `${ok} ONLINE (heartbeat accepted)` : `${bad} no heartbeat${snapshot.hub.last_error ? ` — ${snapshot.hub.last_error}` : (snapshot.hub.comfy_ready ? '' : ' — worker has not reached ComfyUI')}`}`);
227
232
  }
@@ -67,6 +67,13 @@ function summarizeRuntime(entries) {
67
67
  .join(', ') || null;
68
68
  }
69
69
 
70
+ /** Headline of a missing-node-classes cause (node-deps diagnoseMissingClasses). */
71
+ const CAUSE_TITLE = {
72
+ 'deps-missing': 'Python packages missing',
73
+ 'import-failed': 'IMPORT FAILED in the ComfyUI log',
74
+ 'restart-needed': 'ComfyUI restart needed',
75
+ };
76
+
70
77
  /**
71
78
  * @param {object} args
72
79
  * @param {object} args.report - resolver report
@@ -88,9 +95,9 @@ function buildVerificationReport({ report, live = {} }) {
88
95
  let fails = 0;
89
96
  let warns = 0;
90
97
 
91
- const push = (verdict, label, detail) => {
98
+ const push = (verdict, label, detail, extra = null) => {
92
99
  lines.push(line(verdict, label, detail));
93
- checks.push({ verdict, label, detail: detail || null });
100
+ checks.push({ verdict, label, detail: detail || null, ...(extra || {}) });
94
101
  if (verdict === false) fails += 1;
95
102
  else if (verdict === null) warns += 1;
96
103
  };
@@ -134,9 +141,16 @@ function buildVerificationReport({ report, live = {} }) {
134
141
  const nodeEntriesAll = byKind('custom_node');
135
142
  const presentButUnregistered = nodeEntriesAll.length > 0
136
143
  && nodeEntriesAll.every((e) => e.status === 'installed');
137
- push(false, 'ComfyUI node classes', `missing: ${c.missing_node_classes.join(', ')}${presentButUnregistered
138
- ? ' — the node files are present, but the running ComfyUI did not register them (import failed — see <ComfyUI>/comfyui-installer.log — or the instance predates the install); restart ComfyUI and re-run verify'
139
- : ''}`);
144
+ const cause = c.missing_node_classes_cause || null;
145
+ if (cause && cause.kind && cause.kind !== 'unknown') {
146
+ // Installer 0.2.5: the cause, not a generic "re-run" (the fix
147
+ // line is chosen from cause.kind in engine/summary.js).
148
+ push(false, 'ComfyUI node classes', `missing: ${c.missing_node_classes.join(', ')} — ${CAUSE_TITLE[cause.kind] || cause.kind}: ${cause.detail}`, { cause });
149
+ } else {
150
+ push(false, 'ComfyUI node classes', `missing: ${c.missing_node_classes.join(', ')}${presentButUnregistered
151
+ ? ' — the node files are present, but the running ComfyUI did not register them (import failed — see <ComfyUI>/comfyui-installer.log — or the instance predates the install); restart ComfyUI and re-run verify'
152
+ : ''}${cause && cause.detail ? ` (${cause.detail})` : ''}`, cause ? { cause } : null);
153
+ }
140
154
  }
141
155
  } else {
142
156
  push(null, 'ComfyUI API', 'not checked (start ComfyUI and re-run verification)');