@animastor/installer 0.2.14 → 0.2.16

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.14, Node >=20, zero runtime deps
17
+ ├── package.json @animastor/installer 0.2.15, 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)
@@ -121,6 +121,24 @@ it detaches at once (own session, stdin `/dev/null`, output appended to
121
121
  ComfyUI only after the startup script has finished, so waiting inside the
122
122
  script deadlocks.
123
123
 
124
+ `doctor` and `boot` update the INSTALLER ITSELF from the hub (0.2.16): the
125
+ first thing they do is compare the local installer, the installed worker
126
+ bundle and the loaded install manifests with the hub —
127
+ `GET <hub>/installer/sha256` and `GET <hub>/worker-bundle/sha256`. A newer hub
128
+ installer is downloaded (`GET <hub>/installer/bundle`), verified against the
129
+ published sha256, unpacked and put in place of the persistent copy
130
+ (`~/animastor/installer`, what the `animastor` command runs); `doctor` then
131
+ re-executes the same command line in that version, `boot` detaches
132
+ `doctor --yes` of that version. The manifests travel inside the hub bundle, so
133
+ their revision is compared there; the adopted bundle sha256 is recorded in
134
+ `install-state.json`, so a bundle rebuilt at the same version (changed
135
+ manifests) is picked up on the next run too. Offline (no network, a 5xx, a
136
+ missing endpoint) the local version runs and the log says so — before 0.2.16
137
+ a node kept 0.2.14 while the hub served 0.2.15, and only a repeated curl
138
+ bootstrap updated it. A local installer newer than the hub is never
139
+ downgraded. `--no-self-update` skips the check (the boot run gives it an 8 s
140
+ timeout so the platform's startup script is never stalled on the network).
141
+
124
142
  Custom-node Python dependencies on type A (0.2.5): the pip requirements of
125
143
  every required profile custom node are checked in the Python of the running
126
144
  `main.py` (taken from `/proc/<pid>`). Missing ones go into a persistent
@@ -201,8 +219,9 @@ otherwise the start is FAILED naming the file and the worker is not spawned.
201
219
  Every install/doctor run first brings the management tools (`animastor`,
202
220
  the persistent installer copy) and an installed worker bundle to its own
203
221
  version — before any check that can end the run — so every printed fix
204
- command exists in the installed `animastor`. Unknown options are an error
205
- (exit 2). When node classes are missing the result names the cause: missing
222
+ command exists in the installed `animastor`. For `doctor`/`boot` the hub
223
+ check above runs before this step, which then applies the ADOPTED version.
224
+ Unknown options are an error (exit 2). When node classes are missing the result names the cause: missing
206
225
  packages, an `IMPORT FAILED` line from the ComfyUI log (`/internal/logs`,
207
226
  the process stdout file, the restart log) or a needed restart.
208
227
 
@@ -222,6 +241,19 @@ is logged with name, size and outcome (`downloaded`, `present, verified sha256
222
241
  — skipped`, `failed: <reason>`). `install`, `doctor` and `resume` append their
223
242
  log to `~/animastor/logs/bootstrap.log`, not only `animastor boot`.
224
243
 
244
+ Custom node updates (0.2.15): a node the installer itself copied from a
245
+ repository subdirectory (marker `.animastor-source.json`, e.g.
246
+ `animastor-voice-ref`) whose commit differs from the manifest pin is updated
247
+ automatically, also in mode `existing` — no question: the pinned copy is staged
248
+ in `<ComfyUI>/.animastor-node-sources/<dir>.new`, the old copy moves to
249
+ `<dir>.prev` (backup of the last update), a failed swap puts the old copy back.
250
+ The plan lists it under Actions (`Update <node>: <old> → <new>`). ComfyUI loads
251
+ the new code only on a restart: a managed ComfyUI is restarted; the platform's
252
+ ComfyUI is restarted when that restart is allowed (`--restart-platform-comfy`
253
+ or the recorded answer), otherwise the result says the old code still runs. A
254
+ git checkout (a user's or third-party node) at another commit stays a review
255
+ item and is never replaced.
256
+
225
257
  ## Manifest resolution (MANIFEST_ROOT contract)
226
258
 
227
259
  1. `/app/artifacts/install-manifests` (baked container layout)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "manifest_version": "1.0.0",
3
- "revision": "2026.11.12-r1",
3
+ "revision": "2026.12.05-r1",
4
4
  "status": "ready",
5
5
  "profile": {
6
6
  "id": "audio/qwen-tts",
@@ -30,7 +30,7 @@
30
30
  "gpu_min_vram_gb": 8,
31
31
  "basis": "minimum_supported",
32
32
  "reference_gpu": "NVIDIA L40S (46068 MiB)",
33
- "derivation": "Estimate, not a measured floor (VOICE_REFERENCES.md): every workflow now loads ONE 1.7B repo — narrator/dialogue the Base model only (voice clone from a locked reference), voice-reference the VoiceDesign model only (3.57 GiB weights + 0.65 GiB speech tokenizer ≈ 4.2 GiB) plus faster-whisper small (≈ 0.5 GiB fp16) and activations; 8 GB leaves headroom. Was 12 GB while the dialogue workflow loaded VoiceDesign + Base together. Known to run on L40S 46 GB; installed on Tesla V100 (E2E, 2026-10-30). Lower it only after a measured run on a smaller card."
33
+ "derivation": "Estimate, not a measured floor (VOICE_REFERENCES.md): every workflow now loads ONE 1.7B repo — narrator/dialogue the Base model only (voice clone from a locked reference), voice-reference the VoiceDesign model only (3.57 GiB weights + 0.65 GiB speech tokenizer ≈ 4.2 GiB) and activations; faster-whisper small runs on the CPU since node 1.1.0 (no VRAM); 8 GB leaves headroom. Was 12 GB while the dialogue workflow loaded VoiceDesign + Base together. Known to run on L40S 46 GB; installed on Tesla V100 (E2E, 2026-10-30). Lower it only after a measured run on a smaller card."
34
34
  },
35
35
  "runtime_requirements": {
36
36
  "comfyui": {
@@ -263,7 +263,7 @@
263
263
  "source": {
264
264
  "kind": "github",
265
265
  "repository": "https://github.com/Animastor/animastor-worker",
266
- "commit": "6a88ad960e47df9fa6e76e4cce5308d9590297c3",
266
+ "commit": "3e8faab16ca8168065e6b85e17ad49f7fdaf2638",
267
267
  "subdirectory": "comfyui-nodes/animastor-voice-ref",
268
268
  "verification": "confirmed"
269
269
  }
@@ -284,7 +284,8 @@
284
284
  },
285
285
  "notes": [
286
286
  "Needs the ffmpeg binary on PATH (normalisation to WAV pcm_s16le mono 24 kHz).",
287
- "faster-whisper device=auto: CUDA float16, else CPU int8 (recorded in the candidate metadata). The ctranslate2 4.6.0 CUDA path on a V100 (sm_70) is NOT verified yet — live check step in reports/2026-11-12/voice-references.md.",
287
+ "Node 1.1.0 (animastor-worker 3e8faab): faster-whisper runs on the CPU (int8) by default — the CUDA path of ctranslate2 4.6.0 crashed the whole ComfyUI natively on a Tesla V100 (sm_70, 05.12.2026); CPU int8: 11 s of audio in ~2 s. GPU only via ANIMASTOR_WHISPER_DEVICE=cuda|auto in the ComfyUI environment. The candidate metadata records whisper_device / compute_type.",
288
+ "An installed copy at an older commit (marker .animastor-source.json) is updated to this pin by installer >= 0.2.15 automatically (old copy kept in .animastor-node-sources/animastor-voice-ref.prev); the platform's ComfyUI is restarted to load the new code when that restart is allowed.",
288
289
  "Installed from a SUBDIRECTORY of the repository (install.source.subdirectory); the installer writes .animastor-source.json (repository + commit) into the node folder so the pinned version stays verifiable."
289
290
  ]
290
291
  },
@@ -665,7 +666,8 @@
665
666
  "Open question 8: ComfyUI-Manager inclusion (D7)",
666
667
  "Open question 12: minimum VRAM is an estimate (12 GB, hardware.derivation) — measure on a smaller card",
667
668
  "VOICE_REFERENCES: confirm LoadAudio (core) on the reference fork c4cfee7 via /object_info",
668
- "VOICE_REFERENCES: ctranslate2 4.6.0 CUDA path on Tesla V100 (sm_70) — measure; CPU int8 fallback is automatic",
669
+ "VOICE_REFERENCES: ctranslate2 4.6.0 CUDA path on Tesla V100 (sm_70) crashes ComfyUI natively (05.12.2026) — faster-whisper is on the CPU by default since node 1.1.0; the GPU path stays opt-in (ANIMASTOR_WHISPER_DEVICE)",
670
+ "Qwen3-TTS is loaded in bf16; a Tesla V100 (sm_70) has no native bf16 — evaluate fp16 on V100 (separate task)",
669
671
  "VOICE_REFERENCES: qwen-tts pip version on the worker (`pip show qwen-tts`)"
670
672
  ]
671
673
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@animastor/installer",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
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": {
@@ -34,6 +34,8 @@
34
34
  * finish (default 600000); still busy → FAILED, exit 1
35
35
  * --force install/doctor: restart the worker for a changed configuration even
36
36
  * when it is busy (the task's result is lost)
37
+ * --no-self-update doctor/boot: skip the hub version check (an OFFLINE run does it
38
+ * automatically: it never waits for an unreachable hub)
37
39
  */
38
40
 
39
41
  const fs = require('fs');
@@ -65,6 +67,7 @@ const overridesMod = require('./engine/overrides');
65
67
  const downloader = require('./engine/downloader');
66
68
  const { resolveRepoBundleDir } = require('./worker-bundle-source');
67
69
  const engineMod = require('./engine/engine');
70
+ const hubSelfUpdateMod = require('./engine/hub-self-update');
68
71
 
69
72
  // ---------------------------------------------------------------------------
70
73
  // Paths (platform-specific defaults; the platform adapter owns them)
@@ -113,7 +116,7 @@ const DEFAULT_HUB_URL = 'https://animastor.org/gpu';
113
116
  // Argument parsing
114
117
  // ---------------------------------------------------------------------------
115
118
 
116
- const BOOLEAN_FLAGS = ['yes', 'dry-run', 'resume', 'start-comfy', 'start-worker', 'no-start-comfy', 'no-start-worker', 'all', 'accept-reference-runtime', 'accept-runtime-change', 'install-tools', 'no-tools', 'new-key', 'follow', 'no-fix', 'restart-platform-comfy', 'no-restart-platform-comfy', 'accept-node-deps-overrides', 'force', 'help'];
119
+ const BOOLEAN_FLAGS = ['yes', 'dry-run', 'resume', 'start-comfy', 'start-worker', 'no-start-comfy', 'no-start-worker', 'all', 'accept-reference-runtime', 'accept-runtime-change', 'install-tools', 'no-tools', 'new-key', 'follow', 'no-fix', 'restart-platform-comfy', 'no-restart-platform-comfy', 'accept-node-deps-overrides', 'force', 'no-self-update', 'help'];
117
120
 
118
121
  /**
119
122
  * Every option that takes a value. Installer 0.2.5: an option that is in
@@ -619,6 +622,7 @@ async function platformNodeDepsGate(io, {
619
622
  instance, state = null, root, manifests, flags = {}, boot = false, yes = false, prompt = null,
620
623
  waitMs = 600000, logger = null, statePath = null, sleep = null, intervalMs = 3000, progressMs = 30000,
621
624
  workerDir = null, platformGraceMs = 30000, otherManifests = [], command = 'doctor',
625
+ codeChanged = [],
622
626
  } = {}) {
623
627
  const out = {
624
628
  instance, checked: false, installed: [], restarted: false, pid_changed: false, failed: false, reason: null, record: {},
@@ -654,6 +658,7 @@ async function platformNodeDepsGate(io, {
654
658
  out.checked = true;
655
659
  for (const e of check.errors) warn(`custom-node dependency check: ${e}`);
656
660
  let needRestart = !!(out.prestartup && (out.prestartup.status === 'created' || out.prestartup.status === 'updated'));
661
+ if (Array.isArray(codeChanged) && codeChanged.length > 0) needRestart = true; // 0.2.15: updated node code
657
662
  let snapshotOf = null;
658
663
  const dropSnap = () => { if (snapshotOf) overridesMod.dropSnapshot(io, snapshotOf); snapshotOf = null; };
659
664
  if (check.nodes.length === 0) {
@@ -793,7 +798,10 @@ async function platformNodeDepsGate(io, {
793
798
  const have = instance.url ? await comfyuiMod.objectInfoClasses(io, instance.url) : null;
794
799
  if (!have && !needRestart) return out; // not answering — the platform gate/verification reports it
795
800
  const missingNow = have ? expectClasses.filter((c) => !have.has(c)) : expectClasses;
796
- if (missingNow.length === 0) {
801
+ // 0.2.15: an updated node keeps its classes, but the running process still
802
+ // has the OLD code — it is loaded only by a restart
803
+ const codeUpdated = Array.isArray(codeChanged) && codeChanged.length > 0;
804
+ if (missingNow.length === 0 && !codeUpdated) {
797
805
  if (needRestart) info(`the running ComfyUI (pid ${instance.pid}) already has the node classes — no restart needed`);
798
806
  return out;
799
807
  }
@@ -813,19 +821,25 @@ async function platformNodeDepsGate(io, {
813
821
  info(`node classes missing in the running ComfyUI (pid ${instance.pid}): ${missingNow.join(', ')} — ${diag.detail}`);
814
822
  }
815
823
  if (restartAllowed === null && interactive) {
816
- restartAllowed = await prompt.confirm(`The running ComfyUI (pid ${instance.pid}) loaded the custom nodes before their dependencies were in place. Restart it now (same command line, working directory and environment)?`, { defaultYes: true });
824
+ const why = missingNow.length === 0
825
+ ? `runs the old code of the updated custom node(s) ${codeChanged.join(', ')}`
826
+ : 'loaded the custom nodes before their dependencies were in place';
827
+ restartAllowed = await prompt.confirm(`The running ComfyUI (pid ${instance.pid}) ${why}. Restart it now (same command line, working directory and environment)?`, { defaultYes: true });
817
828
  out.record.restartPlatformComfy = restartAllowed;
818
829
  }
819
830
  if (restartAllowed !== true) {
820
831
  // A ComfyUI that is not ours is never stopped without the option.
821
832
  out.failed = true;
822
- out.reason = `custom-node dependencies are in place, but the platform's ComfyUI (pid ${instance.pid}) imported the nodes before that and was not restarted (restart of the platform's ComfyUI is off): ${missingNow.join(', ')} missing`;
833
+ out.reason = missingNow.length === 0
834
+ ? `custom node(s) ${codeChanged.join(', ')} updated on disk, but the platform's ComfyUI (pid ${instance.pid}) still runs the old code and was not restarted (restart of the platform's ComfyUI is off)`
835
+ : `custom-node dependencies are in place, but the platform's ComfyUI (pid ${instance.pid}) imported the nodes before that and was not restarted (restart of the platform's ComfyUI is off): ${missingNow.join(', ')} missing`;
823
836
  out.fix = `restart the ComfyUI from the platform console, or run: ${tool} doctor --restart-platform-comfy`;
824
837
  return out;
825
838
  }
839
+ if (codeUpdated) info(`custom node(s) updated: ${codeChanged.join(', ')} — restarting the platform's ComfyUI (pid ${instance.pid}) so it loads the new code`);
826
840
  const restartLog = workerDir ? path.join(path.dirname(path.resolve(workerDir)), 'logs', 'comfyui-restart.log') : null;
827
841
  const rr = await nodeDeps.restartForeignComfyUI(io, {
828
- pid: instance.pid, timeoutMs: waitMs, intervalMs, expectClasses: missingNow, sleep, log: logger, onProgress: info, progressMs,
842
+ pid: instance.pid, timeoutMs: waitMs, intervalMs, expectClasses: missingNow.length > 0 ? missingNow : expectClasses, sleep, log: logger, onProgress: info, progressMs,
829
843
  platformGraceMs, logFile: restartLog,
830
844
  });
831
845
  out.restarted = rr.stopped;
@@ -1002,7 +1016,7 @@ function bootChildArgs(flags, { cliPath = __filename, defaultWaitMs = 600000 } =
1002
1016
  * node dependencies, restarts the platform's ComfyUI when needed and starts
1003
1017
  * the worker.
1004
1018
  */
1005
- function cmdBoot(flags, { io = createRealIo(), spawn = require('child_process').spawn, execPath = process.execPath, cliPath = __filename, now = () => new Date() } = {}) {
1019
+ async function cmdBoot(flags, { io = createRealIo(), spawn = require('child_process').spawn, execPath = process.execPath, cliPath = __filename, now = () => new Date() } = {}) {
1006
1020
  const logFile = bootLogPath(flags);
1007
1021
  let fd = null;
1008
1022
  try {
@@ -1010,12 +1024,41 @@ function cmdBoot(flags, { io = createRealIo(), spawn = require('child_process').
1010
1024
  fd = fs.openSync(logFile, 'a');
1011
1025
  const btime = systemBootTime(io);
1012
1026
  fs.writeSync(fd, `\n===== animastor boot ${now().toISOString()} (system boot ${btime || 'unknown'}) =====\n`);
1013
- const args = bootChildArgs(flags, { cliPath });
1027
+ // Installer 0.2.16 — the hub version check runs BEFORE the detach: the
1028
+ // detached `doctor --yes` must be the adopted version, so a node that
1029
+ // boots after a hub release updates itself (live 05.12: boot detached
1030
+ // the local 0.2.14 doctor while the hub served 0.2.15).
1031
+ let childCli = cliPath;
1032
+ const selfUpdate = await preflightSelfUpdateFromHub(io, {
1033
+ flags,
1034
+ statePath: resolveStatePath(flags),
1035
+ workerDir: resolveWorkerDir(flags),
1036
+ hubUrl: resolveHubUrl(flags),
1037
+ manifests: recordedManifests(io, flags),
1038
+ boot: true,
1039
+ // the platform's startup script waits for this process: a
1040
+ // blackholed network must not stall it for the doctor timeout
1041
+ timeoutMs: 8000,
1042
+ });
1043
+ for (const n of selfUpdate.notes || []) {
1044
+ fs.writeSync(fd, `[${n.level === 'warn' ? '!' : 'i'}] ${n.text}\n`);
1045
+ }
1046
+ const adopted = selfUpdate.status === 'updated' && !!selfUpdate.cliPath;
1047
+ if (adopted) {
1048
+ childCli = selfUpdate.cliPath;
1049
+ fs.writeSync(fd, `animastor boot: installer ${selfUpdate.version || '?'} adopted — the detached doctor runs it\n`);
1050
+ }
1051
+ const args = bootChildArgs(flags, { cliPath: childCli });
1014
1052
  const child = spawn(execPath, args, {
1015
1053
  detached: true,
1016
1054
  stdio: ['ignore', fd, fd],
1017
1055
  cwd: homeDir(),
1018
- env: { ...process.env, ANIMASTOR_BOOT: '1' },
1056
+ // An ADOPTED version needs no second check in the detached doctor.
1057
+ // Anything else (offline, a failed download) is retried there —
1058
+ // the boot check never blocks the node startup script on it.
1059
+ env: adopted
1060
+ ? { ...process.env, ANIMASTOR_BOOT: '1', [hubSelfUpdateMod.SELF_UPDATE_ENV]: '1' }
1061
+ : { ...process.env, ANIMASTOR_BOOT: '1' },
1019
1062
  });
1020
1063
  if (child && typeof child.unref === 'function') child.unref();
1021
1064
  const pid = child && child.pid;
@@ -1043,6 +1086,96 @@ function installedToolsVersion(io, flags) {
1043
1086
  try { return JSON.parse(String(io.fs.readFileSync(path.join(dir, 'package.json'), 'utf8'))).version || null; } catch (_) { return null; }
1044
1087
  }
1045
1088
 
1089
+ /** The persistent installer copy the `animastor` command runs (<base>/installer). */
1090
+ function persistentInstallerDir(flags) {
1091
+ return path.join(path.dirname(resolveToolsDir(flags)), 'installer');
1092
+ }
1093
+
1094
+ /** Manifests of the profiles recorded in install-state (the boot path has no --profile). */
1095
+ function recordedManifests(io, flags) {
1096
+ const st = stateStore.loadState(io, resolveStatePath(flags));
1097
+ const profiles = st && Array.isArray(st.profiles) ? st.profiles : [];
1098
+ const out = [];
1099
+ for (const id of profiles) {
1100
+ try { out.push(manifest.loadManifest(id)); } catch (_) { /* a manifest removed by a release says nothing about the version */ }
1101
+ }
1102
+ return out;
1103
+ }
1104
+
1105
+ /**
1106
+ * Installer 0.2.16 — the FIRST step of `doctor` and `boot`: compare the local
1107
+ * installer / worker bundle / install manifests with the hub
1108
+ * (`/installer/sha256`, `/worker-bundle/sha256`) and adopt a newer hub
1109
+ * installer (verified bundle → persistent copy → re-exec by the caller).
1110
+ *
1111
+ * Offline (no network, a 5xx, a missing endpoint) is NOT an error: the run
1112
+ * continues with the local version and says so. So does a failed update — the
1113
+ * running version keeps working, the persistent copy is untouched.
1114
+ *
1115
+ * @returns {Promise<object>} hubSelfUpdate result ({ status, notes, cliPath, … })
1116
+ */
1117
+ async function preflightSelfUpdateFromHub(io, {
1118
+ flags = {}, statePath = null, workerDir = null, hubUrl = null, manifests = [], logger = null,
1119
+ boot = false, timeoutMs = undefined,
1120
+ } = {}) {
1121
+ const skip = (reason) => ({ status: 'skipped', reason, notes: [], hub: null, decision: null, cliPath: null, version: null });
1122
+ if (flags['no-self-update']) return skip('--no-self-update');
1123
+ if (process.env[hubSelfUpdateMod.SELF_UPDATE_ENV]) return skip(`already updated in this run (${hubSelfUpdateMod.SELF_UPDATE_ENV})`);
1124
+ const res = await hubSelfUpdateMod.hubSelfUpdate(io, {
1125
+ hubUrl,
1126
+ ownVersion: ownVersion(),
1127
+ bundleVersion: workerDir ? workerMod.readPkgVersion(io, workerDir) : null,
1128
+ manifests,
1129
+ statePath,
1130
+ persistentDir: persistentInstallerDir(flags),
1131
+ nodeBin,
1132
+ timeoutMs,
1133
+ });
1134
+ // The boot path writes its own log lines (its stdout is bootstrap.log);
1135
+ // with a logger the lines go through the run's renderer.
1136
+ for (const n of res.notes || []) {
1137
+ if (logger) { if (n.level === 'warn') logger.warn(n.text); else logger.info(n.text); }
1138
+ else if (!boot) console.log(`[${n.level === 'warn' ? '!' : 'i'}] ${n.text}`);
1139
+ }
1140
+ return res;
1141
+ }
1142
+
1143
+ /**
1144
+ * Re-execute THIS command line in the just-adopted installer version. The
1145
+ * code of the running process cannot be replaced in place, and every fix
1146
+ * command of the result must belong to the version that produced it.
1147
+ * The child starts from the persistent copy (`<base>/installer`), gets the
1148
+ * same stdio and the SELF_UPDATE_ENV marker (no second check, no loop).
1149
+ * @returns {Promise<number|null>} null when the child could not be started
1150
+ */
1151
+ function reexecCli({
1152
+ cliPath, argv = process.argv, nodeBin = process.execPath, env = process.env,
1153
+ spawn = require('child_process').spawn, exit = (code) => process.exit(code),
1154
+ } = {}) {
1155
+ return new Promise((resolve) => {
1156
+ let done = false;
1157
+ const finish = (status) => { if (done) return; done = true; exit(status); resolve(status); };
1158
+ let child;
1159
+ try {
1160
+ child = spawn(nodeBin, [cliPath, ...argv.slice(2)], {
1161
+ stdio: 'inherit',
1162
+ env: { ...env, [hubSelfUpdateMod.SELF_UPDATE_ENV]: '1' },
1163
+ });
1164
+ } catch (err) {
1165
+ console.error(`animastor: could not start the updated installer ${cliPath}: ${err.message}`);
1166
+ process.exitCode = 1;
1167
+ resolve(null);
1168
+ return;
1169
+ }
1170
+ child.on('error', (err) => {
1171
+ console.error(`animastor: could not start the updated installer ${cliPath}: ${err.message}`);
1172
+ process.exitCode = 1;
1173
+ if (!done) { done = true; resolve(null); }
1174
+ });
1175
+ child.on('exit', (code, signal) => finish(signal ? 1 : (code == null ? 1 : code)));
1176
+ });
1177
+ }
1178
+
1046
1179
  /**
1047
1180
  * Installer 0.2.5 — FIRST change of every install/doctor run, before any
1048
1181
  * check that can end the run with ✗: the management tools (the `animastor`
@@ -1253,6 +1386,24 @@ async function cmdInstall(flags, { doctor = false } = {}) {
1253
1386
  const screen = createScreen();
1254
1387
  const logger = createLogger({ io: realIo, sink: (line) => screen.print(line) });
1255
1388
  const loadedManifests = flags.profiles.map((p) => manifest.loadManifest(p));
1389
+
1390
+ // Installer 0.2.16 — doctor/boot ask the HUB first (before the banner and
1391
+ // before any change): is this installer behind? A newer hub installer is
1392
+ // adopted and this command line is re-executed in that version; offline,
1393
+ // the local version runs and the result says so (live 05.12: doctor on a
1394
+ // node ran 0.2.14 while the hub served 0.2.15 — nothing was updated).
1395
+ if (doctor && !dryRun) {
1396
+ const selfUpdate = await preflightSelfUpdateFromHub(realIo, {
1397
+ flags, statePath, workerDir, hubUrl, manifests: loadedManifests, logger, boot,
1398
+ });
1399
+ if (selfUpdate.status === 'updated' && selfUpdate.cliPath) {
1400
+ // The code of this process is already loaded: the adopted version
1401
+ // must run the command.
1402
+ await reexecCli({ cliPath: selfUpdate.cliPath });
1403
+ return;
1404
+ }
1405
+ }
1406
+
1256
1407
  const hubVersion = doctor
1257
1408
  ? await detectHubVersion(realIo, hubUrl, { known: process.env.ANIMASTOR_HUB_VERSION || (priorState && priorState.hub_version) || null })
1258
1409
  : (process.env.ANIMASTOR_HUB_VERSION || null);
@@ -1617,8 +1768,9 @@ async function cmdInstall(flags, { doctor = false } = {}) {
1617
1768
  ? () => prompt.secret('The Worker Key is revoked or wrong. Paste a new Worker Key from Animastor → Settings → Workers (hidden input, Enter = skip)')
1618
1769
  : null,
1619
1770
  // 0.2.13: the node-deps gate again, for nodes installed by this run
1620
- platformNodeDeps: async (current) => {
1771
+ platformNodeDeps: async (current, extra = {}) => {
1621
1772
  const g = await platformNodeDepsGate(realIo, {
1773
+ codeChanged: extra.codeChanged || [],
1622
1774
  instance: current, state: stateStore.loadState(realIo, statePath), root, manifests: loadedManifests, flags, boot, yes, prompt,
1623
1775
  waitMs: Math.max(180000, comfyWaitMs), logger, statePath, workerDir,
1624
1776
  otherManifests: otherProfileManifests(priorState, flags.profiles, { logger }), command: doctor ? 'doctor' : 'install',
@@ -2349,7 +2501,7 @@ async function main() {
2349
2501
  await cmdDoctor(args.flags);
2350
2502
  break;
2351
2503
  case 'boot':
2352
- cmdBoot(args.flags);
2504
+ await cmdBoot(args.flags);
2353
2505
  break;
2354
2506
  case 'detect':
2355
2507
  await cmdDetect(args.flags);
@@ -2400,6 +2552,7 @@ async function main() {
2400
2552
  console.error(' animastor start | stop | status | logs [-f] | doctor [--new-key] [--wait-job-ms N] [--force] | boot');
2401
2553
  console.error(' boot: node startup script — detaches `doctor --yes` (log ~/animastor/logs/bootstrap.log), exits 0');
2402
2554
  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)');
2555
+ console.error(' --no-self-update doctor/boot: skip the hub installer version check (offline runs skip it themselves)');
2403
2556
  console.error(' --accept-node-deps-overrides consent: the node-deps overlay may replace a package another profile / ComfyUI core uses');
2404
2557
  console.error(' (also: monitor | reboot-worker | reboot-comfyui)');
2405
2558
  console.error(' (--state/--root/--worker-dir/--port override discovery)');
@@ -2429,5 +2582,6 @@ module.exports = {
2429
2582
  restartPlatformComfyDecision, platformNodeDepsGate, nodeDepsFailedResult, recordInstallerOption,
2430
2583
  cmdBoot, bootChildArgs, bootLogPath, teeToBootLog, startupScriptLine,
2431
2584
  preflightSelfUpdate, preflightExtras, installedToolsVersion, ownVersion,
2585
+ preflightSelfUpdateFromHub, reexecCli, persistentInstallerDir, recordedManifests,
2432
2586
  nodeDepsOwnedServices, recordOwnedServices, otherProfileManifests, overridesStep,
2433
2587
  };
@@ -56,7 +56,10 @@ const ENTRY_STATUSES = Object.freeze([
56
56
  'required', 'installed', 'missing', 'incompatible', 'unused', 'unknown',
57
57
  ]);
58
58
 
59
- const ACTIONS = Object.freeze(['install', 'skip', 'review', 'none', 'configure']);
59
+ // 'update' (0.2.15): an installer-copied custom node (subdirectory source with
60
+ // .animastor-source.json) whose commit differs from the manifest pin — replaced
61
+ // by the pinned copy automatically (never a user's git checkout).
62
+ const ACTIONS = Object.freeze(['install', 'skip', 'review', 'none', 'configure', 'update']);
60
63
 
61
64
  const SHARING_VERDICTS = Object.freeze([
62
65
  'shared-compatible', 'shared-conflict', 'requires-isolation', 'unknown',
@@ -464,6 +467,10 @@ function checkCustomNode(dep, env, profiles) {
464
467
  if (shaMatch(wantCommit, haveCommit)) {
465
468
  return { ...base, status: 'installed', grade: 'canonical-version', action: 'skip', found: describeNodeFound(found), notes };
466
469
  }
470
+ if (isInstallerCopiedNode(dep, found)) {
471
+ notes.push(`installed by the Animastor installer at ${haveCommit}; the manifest pins ${wantCommit} — updated automatically (the copy is replaced, a backup is kept)`);
472
+ return { ...base, status: 'installed', grade: 'outdated', action: 'update', expected: wantCommit, found: describeNodeFound(found), notes };
473
+ }
467
474
  notes.push(`installed commit ${haveCommit} differs from manifest pin ${wantCommit}; in 'existing' mode a git-safe checkout is SUGGESTED, never applied automatically`);
468
475
  return { ...base, status: 'incompatible', reason: 'version_mismatch', action: 'review', expected: wantCommit, found: describeNodeFound(found), notes };
469
476
  }
@@ -475,6 +482,18 @@ function checkCustomNode(dep, env, profiles) {
475
482
  return { ...base, status: 'installed', grade: 'presence', action: 'skip', found: describeNodeFound(found), notes };
476
483
  }
477
484
 
485
+ /**
486
+ * 0.2.15: a node the installer itself copied from a repository SUBDIRECTORY
487
+ * (marker .animastor-source.json, no .git) of the repository the manifest names.
488
+ * Only such a node is updated automatically; a git checkout (the user's or a
489
+ * third-party node) stays a review item.
490
+ */
491
+ function isInstallerCopiedNode(dep, found) {
492
+ const src = (dep.install && dep.install.source) || {};
493
+ return !!(found && found.animastor_source === true && src.subdirectory && src.commit
494
+ && src.repository && found.repository && reposEqual(src.repository, found.repository));
495
+ }
496
+
478
497
  function describeNodeExpectation(dep) {
479
498
  const src = (dep.install && dep.install.source) || {};
480
499
  return { directory: dep.install && dep.install.directory, repository: src.repository || null, commit: src.commit || null };
@@ -1202,6 +1221,7 @@ function resolveInstallation({ manifests, environment = null, mode = 'existing',
1202
1221
  const incompatible = entries.filter((e) => e.status === 'incompatible').length;
1203
1222
  const installPlan = entries.filter((e) => e.action === 'install').map((e) => e.id);
1204
1223
  const configurePlan = entries.filter((e) => e.action === 'configure').map((e) => e.id);
1224
+ const updatePlan = entries.filter((e) => e.action === 'update').map((e) => e.id);
1205
1225
  const customizedWorkflows = entries.filter((e) => e.kind === 'workflow' && e.grade === 'customized').map((e) => e.id);
1206
1226
 
1207
1227
  // Hard invariant of Phase 1: resolver never plans destructive operations.
@@ -1227,6 +1247,7 @@ function resolveInstallation({ manifests, environment = null, mode = 'existing',
1227
1247
  blocking: missingRequired + incompatible,
1228
1248
  install_plan: installPlan,
1229
1249
  configure_plan: configurePlan,
1250
+ update_plan: updatePlan,
1230
1251
  customized_workflows: customizedWorkflows,
1231
1252
  },
1232
1253
  warnings,
@@ -700,7 +700,10 @@ async function runInstallation(args) {
700
700
  }
701
701
  }
702
702
  const nodesApproved = !runtimeFatal && nodesStep && nodesStep.action && nodesStep.decision === 'yes';
703
- if (!runtimeFatal && (nodesApproved || retryDeps.length > 0)) {
703
+ // 0.2.15: installer-copied nodes behind the manifest pin are updated
704
+ // without a question — also when nothing is missing (noop step)
705
+ const nodeUpdates = (nodesStep && nodesStep.update) || [];
706
+ if (!runtimeFatal && (nodesApproved || retryDeps.length > 0 || nodeUpdates.length > 0)) {
704
707
  const python = platformAdapter.venvPythonBin(path.join(comfyuiRoot, 'venv'));
705
708
  // A platform ComfyUI imports with ITS interpreter: pip into
706
709
  // <root>/venv is useful only when that is the same Python (0.2.13).
@@ -714,6 +717,7 @@ async function runInstallation(args) {
714
717
  ...(nodesStep || { id: 'custom-nodes', title: 'Custom nodes' }),
715
718
  missing: retryDeps.map((id) => ({ id })),
716
719
  review: [],
720
+ update: nodeUpdates,
717
721
  };
718
722
  const nodeTorchSpec = pickTorchSpec(manifests, decisions, result.warnings, device);
719
723
  const r = await log.step('install custom nodes', () => withBusySync('Installing custom nodes', () => nodes.installCustomNodes(io, {
@@ -772,10 +776,12 @@ async function runInstallation(args) {
772
776
  // the dependency gate of the platform's ComfyUI ran BEFORE the clone and
773
777
  // could not see it, so it runs again (overlay install + restart, 0.2.13).
774
778
  let nodeDepsGate = null;
775
- const freshNodes = (result.results.custom_nodes || []).filter((x) => x.status === 'installed' && x.origin === 'installed');
779
+ // 0.2.15: an UPDATED node (new code, same classes) needs the restart too
780
+ const freshNodes = (result.results.custom_nodes || []).filter((x) => x.status === 'installed' && (x.origin === 'installed' || x.origin === 'updated'));
781
+ const updatedNodes = freshNodes.filter((x) => x.origin === 'updated').map((x) => x.directory);
776
782
  if (!runtimeFatal && foreignComfy && freshNodes.length > 0 && options.platformNodeDeps) {
777
783
  log.info(`checking the Python dependencies of the installed node(s): ${freshNodes.map((x) => x.directory).join(', ')}`);
778
- nodeDepsGate = await options.platformNodeDeps(comfyOwner);
784
+ nodeDepsGate = await options.platformNodeDeps(comfyOwner, { codeChanged: updatedNodes });
779
785
  Object.assign(st.installer_options, nodeDepsGate.record);
780
786
  for (const e of nodeDepsGate.ownedServices || []) state.addOwnedComponent(st, 'services', e);
781
787
  result.results.node_deps_overrides = nodeDepsGate.overrides;
@@ -0,0 +1,373 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Hub self-update (installer 0.2.16).
5
+ *
6
+ * Fact (05.12.2026): after hub v0.4.4 (installer 0.2.15, worker bundle 3.0.1)
7
+ * `animastor doctor --yes --restart-platform-comfy` on a node ran the LOCAL
8
+ * installer 0.2.14 with manifest 2026.11.12-r1 — the node stayed on 0.2.14 and
9
+ * only a repeated curl bootstrap brought 0.2.15, while every report told the
10
+ * user to run `animastor doctor` to update.
11
+ *
12
+ * `preflightSelfUpdate` (0.2.5) brings the management tools and the installed
13
+ * worker bundle to THIS installer's version; it never asks the hub whether THIS
14
+ * installer is old. That question is answered here, FIRST, for `doctor` and
15
+ * `boot`:
16
+ *
17
+ * GET <hub>/installer/sha256 { version, sha256, bytes }
18
+ * GET <hub>/worker-bundle/sha256 { version, sha256, bytes, files }
19
+ *
20
+ * and compared with the local installer, the installed worker bundle and the
21
+ * loaded install manifests. A newer hub installer → the hub bundle
22
+ * (`GET <hub>/installer/bundle`) is downloaded, verified against the published
23
+ * sha256, unpacked, and the persistent installer copy (`<base>/installer` —
24
+ * what the `animastor` command runs) is replaced; the caller then re-execs the
25
+ * run in the new version (`doctor`) or detaches the new version (`boot`).
26
+ *
27
+ * The install manifests travel INSIDE that bundle (ai/install-manifests), so
28
+ * their revision is compared there — the hub publishes no separate manifest
29
+ * revision. The hub bundle sha256 is recorded in install-state, so a bundle
30
+ * rebuilt at the SAME installer version (changed manifests) is still adopted on
31
+ * the next run.
32
+ *
33
+ * Honest failure modes (never a half-installed update):
34
+ * - offline / 5xx / missing endpoint → `offline`: doctor and boot continue
35
+ * with the local version and SAY SO;
36
+ * - a local installer NEWER than the hub → never downgraded;
37
+ * - a sha256 mismatch, an unexpected layout or an unwritable tools dir →
38
+ * `failed`: the running version continues, the persistent copy is untouched.
39
+ */
40
+
41
+ const os = require('os');
42
+ const path = require('path');
43
+
44
+ const management = require('../management');
45
+ const stateStore = require('./state');
46
+ const worker = require('./worker');
47
+ const { compareVersions } = require('../compatibility-resolver');
48
+
49
+ /** Endpoints the hub publishes versions/checksums at. */
50
+ const HUB_ROUTES = Object.freeze({
51
+ installer: '/installer/sha256',
52
+ installer_bundle: '/installer/bundle',
53
+ worker_bundle: '/worker-bundle/sha256',
54
+ });
55
+
56
+ /** Set for the re-executed run: its version was just adopted, no second check. */
57
+ const SELF_UPDATE_ENV = 'ANIMASTOR_SELF_UPDATE';
58
+
59
+ const TIMEOUT_MS = 15000;
60
+
61
+ /** The repo-checkout / bundled package root of a CLI file (…/src/installer/cli.js). */
62
+ function packageRootOf(cliPath) {
63
+ return path.resolve(path.dirname(cliPath || __filename), '..', '..');
64
+ }
65
+
66
+ function hubBase(hubUrl) {
67
+ return String(hubUrl || '').replace(/\/+$/, '');
68
+ }
69
+
70
+ /**
71
+ * What the hub publishes about its installer and worker bundle.
72
+ * A network error, a 5xx or a missing endpoint is `offline` — it says nothing
73
+ * about the versions, so nothing is updated from it.
74
+ * @returns {Promise<{ status: 'ok'|'partial'|'offline', hub_url: string|null,
75
+ * installer: {version: string, sha256: string|null, bytes: number|null}|null,
76
+ * worker_bundle: {version: string, sha256: string|null, bytes: number|null}|null,
77
+ * reason: string|null }>}
78
+ */
79
+ async function fetchHubVersions(io, { hubUrl, timeoutMs = TIMEOUT_MS } = {}) {
80
+ const base = hubBase(hubUrl);
81
+ const out = { status: 'offline', hub_url: base || null, installer: null, worker_bundle: null, reason: null };
82
+ if (!base) { out.reason = 'no hub URL'; return out; }
83
+ if (!io.http || typeof io.http.fetchJson !== 'function') {
84
+ out.reason = 'the io layer cannot reach the hub';
85
+ return out;
86
+ }
87
+ const fetchOne = async (route) => {
88
+ try {
89
+ const res = await io.http.fetchJson(`${base}${route}`, { signal: AbortSignal.timeout(timeoutMs) });
90
+ if (!res || res.status !== 200) return { ok: false, reason: `${route} answered HTTP ${res && res.status}` };
91
+ const json = res.json || {};
92
+ if (typeof json.version !== 'string' || !json.version) return { ok: false, reason: `${route} published no version` };
93
+ return {
94
+ ok: true,
95
+ version: json.version,
96
+ sha256: typeof json.sha256 === 'string' && /^[0-9a-f]{64}$/i.test(json.sha256) ? json.sha256.toLowerCase() : null,
97
+ bytes: typeof json.bytes === 'number' ? json.bytes : null,
98
+ };
99
+ } catch (err) {
100
+ return { ok: false, reason: `${route} is not reachable: ${err && err.message ? err.message : err}` };
101
+ }
102
+ };
103
+ const [installer, bundle] = await Promise.all([fetchOne(HUB_ROUTES.installer), fetchOne(HUB_ROUTES.worker_bundle)]);
104
+ if (installer.ok) out.installer = { version: installer.version, sha256: installer.sha256, bytes: installer.bytes };
105
+ if (bundle.ok) out.worker_bundle = { version: bundle.version, sha256: bundle.sha256, bytes: bundle.bytes };
106
+ const reasons = [installer.reason, bundle.reason].filter(Boolean);
107
+ if (installer.ok && bundle.ok) out.status = 'ok';
108
+ else if (installer.ok || bundle.ok) out.status = 'partial';
109
+ else { out.status = 'offline'; out.reason = reasons.join('; ') || 'the hub is not reachable'; }
110
+ return out;
111
+ }
112
+
113
+ /** Every `revision` of the manifests in <pkgDir>/ai/install-manifests (sorted, unique). */
114
+ function readManifestRevisions(io, pkgDir) {
115
+ const root = path.join(pkgDir, 'ai', 'install-manifests');
116
+ const revisions = [];
117
+ const walk = (dir) => {
118
+ let names = [];
119
+ try { names = io.fs.readdirSync(dir); } catch (_) { return; }
120
+ for (const name of names.sort()) {
121
+ const full = path.join(dir, name);
122
+ if (io.fs.isDirectory(full)) { walk(full); continue; }
123
+ if (!name.endsWith('.json')) continue;
124
+ try {
125
+ const json = JSON.parse(String(io.fs.readFileSync(full, 'utf8')));
126
+ if (json && typeof json.revision === 'string' && json.revision) revisions.push(json.revision);
127
+ } catch (_) { /* an unreadable manifest says nothing about the revision */ }
128
+ }
129
+ };
130
+ walk(root);
131
+ return Array.from(new Set(revisions)).sort();
132
+ }
133
+
134
+ /** Version + manifest revisions of an unpacked installer package. */
135
+ function readBundleInfo(io, pkgDir) {
136
+ let version = null;
137
+ try { version = JSON.parse(String(io.fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf8'))).version || null; } catch (_) { version = null; }
138
+ const revisions = readManifestRevisions(io, pkgDir);
139
+ return { version, manifest_revisions: revisions, manifest_revision: revisions[0] || null };
140
+ }
141
+
142
+ /** Local manifests of this installation (revisions of the recorded profiles). */
143
+ function localManifestRevisions(manifests) {
144
+ return Array.from(new Set((manifests || []).map((m) => m && m.revision).filter(Boolean))).sort();
145
+ }
146
+
147
+ /** Recorded outcome of the last hub self-update (install-state `self_update`). */
148
+ function readRecordedSelfUpdate(io, statePath) {
149
+ if (!statePath) return null;
150
+ const st = stateStore.loadState(io, statePath);
151
+ return st && st.self_update && typeof st.self_update === 'object' ? st.self_update : null;
152
+ }
153
+
154
+ /** Remember which hub installer (version + sha256) this installation adopted. */
155
+ function recordSelfUpdate(io, statePath, info) {
156
+ if (!statePath) return false;
157
+ const st = stateStore.loadState(io, statePath);
158
+ if (!st) return false; // no recorded installation — doctor creates none
159
+ st.self_update = {
160
+ installer_version: info.installer_version || null,
161
+ installer_sha256: info.installer_sha256 || null,
162
+ manifest_revision: info.manifest_revision || null,
163
+ manifest_revisions: info.manifest_revisions || [],
164
+ worker_bundle_version: info.worker_bundle_version || null,
165
+ updated_at: new Date(io.now ? io.now() : Date.now()).toISOString(),
166
+ };
167
+ stateStore.saveState(io, statePath, st, io.now || Date.now);
168
+ return true;
169
+ }
170
+
171
+ /**
172
+ * Pure decision: is this installation behind the hub?
173
+ *
174
+ * installer — the hub publishes a NEWER installer version → adopt it;
175
+ * an OLDER hub version than the local one is never a downgrade;
176
+ * content — same version, but the hub bundle sha256 differs from the one
177
+ * this installation adopted → the hub rebuilt the bundle (its
178
+ * manifests changed) → adopt it;
179
+ * bundle — an installed worker bundle behind the hub is reported;
180
+ * it is refreshed by preflightSelfUpdate / the engine (the
181
+ * installer bundle carries the same files), not by a second
182
+ * installer download.
183
+ *
184
+ * @returns {{ needed: boolean, reasons: Array<{kind: string, have: *|null, want: *|null}>,
185
+ * warnings: string[], bundle_outdated: boolean }}
186
+ */
187
+ function decideHubSelfUpdate({ ownVersion = null, bundleVersion = null, manifestRevisions = [], recorded = null, hub = null } = {}) {
188
+ const out = { needed: false, reasons: [], warnings: [], bundle_outdated: false };
189
+ const hubInstaller = hub && hub.installer ? hub.installer : null;
190
+ if (!hubInstaller || !hubInstaller.version) {
191
+ out.warnings.push('the hub did not publish an installer version — nothing can be compared');
192
+ return out;
193
+ }
194
+ const cmp = ownVersion ? compareVersions(hubInstaller.version, ownVersion) : 1;
195
+ if (cmp > 0) {
196
+ out.needed = true;
197
+ out.reasons.push({ kind: 'installer', have: ownVersion, want: hubInstaller.version });
198
+ } else if (cmp < 0) {
199
+ out.warnings.push(`the local installer ${ownVersion} is newer than the hub's ${hubInstaller.version} — left as is (an installer is never downgraded)`);
200
+ } else if (recorded && recorded.installer_sha256 && hubInstaller.sha256
201
+ && String(recorded.installer_sha256) !== String(hubInstaller.sha256)) {
202
+ // same version, different bundle: rebuilt with other manifests
203
+ out.needed = true;
204
+ out.reasons.push({ kind: 'installer-content', have: String(recorded.installer_sha256).slice(0, 12), want: String(hubInstaller.sha256).slice(0, 12) });
205
+ }
206
+ const hubBundle = hub && hub.worker_bundle ? hub.worker_bundle : null;
207
+ if (hubBundle && hubBundle.version && bundleVersion && hubBundle.version !== bundleVersion) {
208
+ out.bundle_outdated = true;
209
+ }
210
+ return out;
211
+ }
212
+
213
+ /**
214
+ * Download the hub installer bundle, verify the published sha256, unpack it.
215
+ * The caller owns `tmpDir` (persist first, then remove it).
216
+ * @returns {Promise<{ ok: boolean, pkgDir?: string, tmpDir?: string, version?: string|null,
217
+ * manifest_revisions?: string[], manifest_revision?: string|null, sha256?: string, reason?: string }>}
218
+ */
219
+ async function applyHubSelfUpdate(io, { hubUrl, hub, tmpRoot = null } = {}) {
220
+ const base = hubBase(hubUrl);
221
+ const expected = hub && hub.installer ? hub.installer.sha256 : null;
222
+ if (!base) return { ok: false, reason: 'no hub URL' };
223
+ if (!expected) return { ok: false, reason: 'the hub published no installer sha256 — refusing an unverified installer' };
224
+ if (!io.http || typeof io.http.download !== 'function' || typeof io.hashFile !== 'function' || typeof io.exec !== 'function') {
225
+ return { ok: false, reason: 'the io layer cannot download and unpack the hub installer' };
226
+ }
227
+ const tmpDir = path.join(tmpRoot || os.tmpdir(), `animastor-installer-${process.pid}-${Date.now()}`);
228
+ const tarPath = path.join(tmpDir, 'installer-bundle.tar.gz');
229
+ try {
230
+ io.fs.mkdirSync(tmpDir, { recursive: true });
231
+ const dl = await io.http.download({ url: `${base}${HUB_ROUTES.installer_bundle}`, dest: tarPath });
232
+ if (!dl || dl.status !== 200) {
233
+ return { ok: false, tmpDir, reason: `installer bundle download failed (HTTP ${dl && dl.status})` };
234
+ }
235
+ const actual = await io.hashFile(tarPath);
236
+ if (String(actual).toLowerCase() !== String(expected).toLowerCase()) {
237
+ return { ok: false, tmpDir, reason: `installer bundle sha256 mismatch (expected ${String(expected).slice(0, 12)}…, got ${String(actual).slice(0, 12)}…) — the download was NOT used` };
238
+ }
239
+ const untar = io.exec('tar', ['-xzf', tarPath, '-C', tmpDir]);
240
+ if (!untar || untar.code !== 0) {
241
+ return { ok: false, tmpDir, reason: `installer bundle unpack failed: ${String((untar && (untar.stderr || untar.error)) || '').slice(-200)}` };
242
+ }
243
+ const pkgDir = path.join(tmpDir, 'animastor-installer');
244
+ const cli = path.join(pkgDir, 'src', 'installer', 'cli.js');
245
+ if (!io.fs.isDirectory(pkgDir) || !io.fs.existsSync(cli)) {
246
+ return { ok: false, tmpDir, reason: 'installer bundle layout unexpected (animastor-installer/src/installer/cli.js missing)' };
247
+ }
248
+ const info = readBundleInfo(io, pkgDir);
249
+ if (!info.version) return { ok: false, tmpDir, reason: 'installer bundle carries no package.json version' };
250
+ return { ok: true, pkgDir, tmpDir, version: info.version, manifest_revisions: info.manifest_revisions, manifest_revision: info.manifest_revision, sha256: String(actual).toLowerCase() };
251
+ } catch (err) {
252
+ return { ok: false, tmpDir, reason: `installer bundle fetch failed: ${err && err.message ? err.message : err}` };
253
+ } finally {
254
+ try { if (io.fs.existsSync(tarPath)) io.fs.unlinkSync(tarPath); } catch (_) { /* best effort */ }
255
+ }
256
+ }
257
+
258
+ /** Human line for the version comparison (doctor/boot prints it). */
259
+ function versionsLine({ ownVersion, bundleVersion, manifestRevisions = [], hub }) {
260
+ const hubInstaller = hub && hub.installer ? hub.installer.version : 'unknown';
261
+ const hubBundle = hub && hub.worker_bundle ? hub.worker_bundle.version : 'unknown';
262
+ const manifests = manifestRevisions.length > 0 ? manifestRevisions.join(', ') : 'unknown';
263
+ return `hub: installer ${hubInstaller}, worker bundle ${hubBundle}; local: installer ${ownVersion || 'unknown'}, worker bundle ${bundleVersion || 'unknown'}, manifests ${manifests}`;
264
+ }
265
+
266
+ /**
267
+ * The whole check: hub versions → decision → download/verify/unpack → replace
268
+ * the persistent installer copy → record the adopted sha256 in install-state.
269
+ * Never throws; never leaves a half-installed update behind.
270
+ *
271
+ * @returns {Promise<{ status: 'skipped'|'current'|'offline'|'updated'|'failed',
272
+ * reason: string|null, hub: object|null, decision: object|null,
273
+ * notes: Array<{level: 'info'|'warn', text: string}>,
274
+ * cliPath: string|null, version: string|null, manifest_revision: string|null }>}
275
+ */
276
+ async function hubSelfUpdate(io, {
277
+ hubUrl, ownVersion = null, bundleVersion = null, manifests = [], statePath = null,
278
+ persistentDir, timeoutMs = TIMEOUT_MS, tmpRoot = null, record = true,
279
+ } = {}) {
280
+ const notes = [];
281
+ const result = { status: 'skipped', reason: null, hub: null, decision: null, notes, cliPath: null, version: null, manifest_revision: null };
282
+ const manifestRevisions = localManifestRevisions(manifests);
283
+ if (!persistentDir) {
284
+ result.reason = 'no persistent installer directory';
285
+ notes.push({ level: 'warn', text: `hub self-update skipped: ${result.reason}` });
286
+ return result;
287
+ }
288
+ const hub = await fetchHubVersions(io, { hubUrl, timeoutMs });
289
+ result.hub = hub;
290
+ if (hub.status === 'offline') {
291
+ result.status = 'offline';
292
+ result.reason = hub.reason;
293
+ notes.push({ level: 'warn', text: `the hub ${hub.hub_url || ''} is not reachable (${hub.reason}) — continuing with the local installer ${ownVersion || 'unknown'} and worker bundle ${bundleVersion || 'unknown'}; nothing was updated` });
294
+ return result;
295
+ }
296
+ const recorded = readRecordedSelfUpdate(io, statePath);
297
+ const decision = decideHubSelfUpdate({ ownVersion, bundleVersion, manifestRevisions, recorded, hub });
298
+ result.decision = decision;
299
+ notes.push({ level: 'info', text: versionsLine({ ownVersion, bundleVersion, manifestRevisions, hub }) });
300
+ for (const w of decision.warnings) notes.push({ level: 'warn', text: w });
301
+ if (hub.status === 'partial' && !(hub.installer && hub.installer.version)) {
302
+ result.status = 'failed';
303
+ result.reason = hub.reason || 'the hub did not publish an installer version';
304
+ notes.push({ level: 'warn', text: `hub self-update skipped: ${result.reason} — continuing with the local installer ${ownVersion || 'unknown'}` });
305
+ return result;
306
+ }
307
+ if (decision.bundle_outdated) {
308
+ notes.push({ level: 'info', text: `worker bundle ${bundleVersion} → ${hub.worker_bundle.version} is updated by the install preflight (the hub installer bundle carries the same files)` });
309
+ }
310
+ if (!decision.needed) {
311
+ result.status = 'current';
312
+ result.reason = decision.warnings.length > 0 ? decision.warnings[0] : null;
313
+ return result;
314
+ }
315
+
316
+ const applied = await applyHubSelfUpdate(io, { hubUrl, hub, tmpRoot });
317
+ if (!applied.ok) {
318
+ if (applied.tmpDir) { try { io.fs.rmSync(applied.tmpDir, { recursive: true, force: true }); } catch (_) { /* best effort */ } }
319
+ result.status = 'failed';
320
+ result.reason = applied.reason;
321
+ notes.push({ level: 'warn', text: `hub self-update failed: ${applied.reason} — continuing with the local installer ${ownVersion || 'unknown'}` });
322
+ return result;
323
+ }
324
+ let cliPath = null;
325
+ try {
326
+ cliPath = management.persistInstaller(io, { srcRoot: applied.pkgDir, destRoot: persistentDir });
327
+ } catch (err) {
328
+ result.status = 'failed';
329
+ result.reason = `the persistent installer copy ${persistentDir} could not be replaced: ${err.message}`;
330
+ notes.push({ level: 'warn', text: `hub self-update failed: ${result.reason} — continuing with the local installer ${ownVersion || 'unknown'}` });
331
+ return result;
332
+ } finally {
333
+ try { io.fs.rmSync(applied.tmpDir, { recursive: true, force: true }); } catch (_) { /* best effort */ }
334
+ }
335
+ result.status = 'updated';
336
+ result.cliPath = cliPath;
337
+ result.version = applied.version;
338
+ result.manifest_revision = applied.manifest_revision;
339
+ if (record) {
340
+ recordSelfUpdate(io, statePath, {
341
+ installer_version: applied.version,
342
+ installer_sha256: applied.sha256,
343
+ manifest_revision: applied.manifest_revision,
344
+ manifest_revisions: applied.manifest_revisions,
345
+ worker_bundle_version: hub.worker_bundle ? hub.worker_bundle.version : null,
346
+ });
347
+ }
348
+ const why = decision.reasons.map((r) => (r.kind === 'installer'
349
+ ? `installer ${r.have || 'unknown'} → ${r.want}`
350
+ : `the hub rebuilt installer ${applied.version} (suite sha256 ${r.have}… → ${r.want}…, its manifests changed)`));
351
+ notes.push({ level: 'info', text: `installer updated: ${why.join('; ')}` });
352
+ if (applied.manifest_revision && !manifestRevisions.includes(applied.manifest_revision)) {
353
+ notes.push({ level: 'info', text: `install manifests ${manifestRevisions.join(', ') || 'unknown'} → ${applied.manifest_revisions.join(', ')}` });
354
+ }
355
+ return result;
356
+ }
357
+
358
+ module.exports = {
359
+ HUB_ROUTES,
360
+ SELF_UPDATE_ENV,
361
+ TIMEOUT_MS,
362
+ packageRootOf,
363
+ fetchHubVersions,
364
+ readManifestRevisions,
365
+ readBundleInfo,
366
+ localManifestRevisions,
367
+ readRecordedSelfUpdate,
368
+ recordSelfUpdate,
369
+ decideHubSelfUpdate,
370
+ applyHubSelfUpdate,
371
+ versionsLine,
372
+ hubSelfUpdate,
373
+ };
@@ -12,7 +12,10 @@
12
12
  *
13
13
  * Already-installed compatible nodes are KEPT — never reinstalled without
14
14
  * need. Incompatible nodes stop their step pending a user decision; no
15
- * destructive replacement happens automatically.
15
+ * destructive replacement happens automatically — except (0.2.15) a node the
16
+ * installer itself copied from a repository subdirectory (marker
17
+ * .animastor-source.json): it is updated to the manifest pin, old copy kept
18
+ * as <root>/.animastor-node-sources/<dir>.prev.
16
19
  */
17
20
 
18
21
  const path = require('path');
@@ -61,6 +64,114 @@ function pipInstallRequirements(io, { root, reqPath, python, torchSpec, log = nu
61
64
  /** marker written into a node installed from a repository subdirectory (probe reads it) */
62
65
  const SOURCE_MARKER = '.animastor-source.json';
63
66
 
67
+ /**
68
+ * Clone src.repository OUTSIDE custom_nodes, check out src.commit, copy
69
+ * src.subdirectory to `dest`, write the source marker; staging is always removed.
70
+ * @returns {null|{status:'blocked'|'failed', reason:string}} null = copied
71
+ */
72
+ function copySubdirectory(io, { root, dep, dirName, src, dest }) {
73
+ const sub = String(src.subdirectory);
74
+ if (path.isAbsolute(sub) || sub.split(/[\\/]/).includes('..')) {
75
+ return { status: 'blocked', reason: `bad subdirectory ${JSON.stringify(sub)} for ${dep.id}` };
76
+ }
77
+ if (!src.commit) {
78
+ return { status: 'blocked', reason: `${dep.id}: a subdirectory source needs a pinned commit` };
79
+ }
80
+ const staging = path.join(root, '.animastor-node-sources', dirName);
81
+ io.fs.rmSync(staging, { recursive: true, force: true });
82
+ io.fs.mkdirSync(path.dirname(staging), { recursive: true });
83
+ let c = io.exec('git', ['clone', src.repository, staging]);
84
+ if (c.code !== 0) {
85
+ io.fs.rmSync(staging, { recursive: true, force: true });
86
+ return { status: 'failed', reason: `git clone ${src.repository} failed: ${String(c.stderr || c.error).slice(-300)}` };
87
+ }
88
+ c = io.exec('git', ['-C', staging, 'checkout', src.commit]);
89
+ if (c.code !== 0) {
90
+ io.fs.rmSync(staging, { recursive: true, force: true });
91
+ return { status: 'failed', reason: `git checkout ${src.commit} failed: ${String(c.stderr).slice(-300)}` };
92
+ }
93
+ const from = path.join(staging, sub);
94
+ if (!io.fs.isDirectory(from)) {
95
+ io.fs.rmSync(staging, { recursive: true, force: true });
96
+ return { status: 'failed', reason: `subdirectory ${sub} not found in ${src.repository}@${src.commit}` };
97
+ }
98
+ c = io.exec('cp', ['-a', from, dest]);
99
+ io.fs.rmSync(staging, { recursive: true, force: true });
100
+ if (c.code !== 0) return { status: 'failed', reason: `copy of ${sub} failed: ${String(c.stderr || c.error).slice(-300)}` };
101
+ io.fs.writeFileSync(path.join(dest, SOURCE_MARKER), JSON.stringify({ repository: src.repository, commit: src.commit, subdirectory: sub }, null, 2) + '\n');
102
+ return null;
103
+ }
104
+
105
+ function readSourceMarker(io, dir) {
106
+ try {
107
+ const m = JSON.parse(io.fs.readFileSync(path.join(dir, SOURCE_MARKER), 'utf8'));
108
+ return m && typeof m === 'object' ? m : null;
109
+ } catch (_) { return null; }
110
+ }
111
+
112
+ /**
113
+ * 0.2.15 — update a node the installer copied from a repository subdirectory
114
+ * (marker .animastor-source.json, same repository) to the manifest pin:
115
+ * the pinned copy is staged in <root>/.animastor-node-sources/<dir>.new,
116
+ * the current one moves to <dir>.prev (the backup of the last update), the
117
+ * new one takes its place; a failed swap puts the old copy back. A git
118
+ * checkout or a node without the marker is never touched.
119
+ * @returns {{ status: 'installed'|'blocked'|'failed', origin?: 'updated', directory?, from?, to?, reason? }}
120
+ */
121
+ function updateCustomNode(io, { root, dep, python = null, torchSpec = null, log = null }) {
122
+ const src = (dep.install && dep.install.source) || {};
123
+ const dirName = (dep.install && dep.install.directory) || dep.name;
124
+ const target = path.join(root, 'custom_nodes', dirName);
125
+ if (!src.subdirectory || !src.commit || !src.repository) {
126
+ return { status: 'blocked', reason: `${dep.id}: only a node pinned to a repository subdirectory + commit is updated automatically` };
127
+ }
128
+ if (!io.fs.isDirectory(target)) return { status: 'failed', reason: `${target} is not there any more — re-run to install it` };
129
+ if (io.fs.existsSync(path.join(target, '.git'))) {
130
+ return { status: 'blocked', reason: `${target} is a git checkout — not replaced automatically` };
131
+ }
132
+ const marker = readSourceMarker(io, target);
133
+ const norm = (u) => String(u || '').replace(/\.git$/, '').replace(/\/+$/, '').toLowerCase();
134
+ if (!marker || norm(marker.repository) !== norm(src.repository)) {
135
+ return { status: 'blocked', reason: `${target} was not installed by the Animastor installer from ${src.repository} — not replaced automatically` };
136
+ }
137
+ const from = typeof marker.commit === 'string' ? marker.commit : null;
138
+ if (from === src.commit) return { status: 'installed', origin: 'pre-existing', directory: dirName, reason: 'already at the manifest pin' };
139
+
140
+ const base = path.join(root, '.animastor-node-sources');
141
+ const fresh = path.join(base, `${dirName}.new`);
142
+ const backup = path.join(base, `${dirName}.prev`);
143
+ io.fs.mkdirSync(base, { recursive: true });
144
+ io.fs.rmSync(fresh, { recursive: true, force: true });
145
+ const staged = copySubdirectory(io, { root, dep, dirName, src, dest: fresh });
146
+ if (staged) {
147
+ io.fs.rmSync(fresh, { recursive: true, force: true });
148
+ return staged;
149
+ }
150
+ io.fs.rmSync(backup, { recursive: true, force: true });
151
+ try {
152
+ io.fs.renameSync(target, backup);
153
+ } catch (err) {
154
+ io.fs.rmSync(fresh, { recursive: true, force: true });
155
+ return { status: 'failed', reason: `could not move the old ${dirName} aside: ${err.message}` };
156
+ }
157
+ try {
158
+ io.fs.renameSync(fresh, target);
159
+ } catch (err) {
160
+ try { io.fs.renameSync(backup, target); } catch (_) { /* reported below */ }
161
+ io.fs.rmSync(fresh, { recursive: true, force: true });
162
+ return { status: 'failed', reason: `could not put the new ${dirName} in place (old copy restored): ${err.message}` };
163
+ }
164
+ const req = path.join(target, 'requirements.txt');
165
+ if (io.fs.existsSync(req) && python) {
166
+ const pip = pipInstallRequirements(io, { root, reqPath: req, python, torchSpec, log });
167
+ if (!pip.ok) {
168
+ return { status: 'installed', origin: 'updated', directory: dirName, from, to: src.commit, pip_output: pip.output, reason: 'updated; python dependencies incomplete — see warnings' };
169
+ }
170
+ }
171
+ if (log) log.info(`custom node updated: ${dirName} ${String(from || '?').slice(0, 7)} → ${src.commit.slice(0, 7)} (previous copy: ${backup})`);
172
+ return { status: 'installed', origin: 'updated', directory: dirName, from, to: src.commit };
173
+ }
174
+
64
175
  function installCustomNode(io, { root, dep, python = null, torchSpec = null, retryDeps = false, log = null }) {
65
176
  const src = (dep.install && dep.install.source) || {};
66
177
  const dirName = (dep.install && dep.install.directory) || dep.name;
@@ -91,35 +202,8 @@ function installCustomNode(io, { root, dep, python = null, torchSpec = null, ret
91
202
  // animastor-worker/comfyui-nodes/animastor-voice-ref): clone OUTSIDE
92
203
  // custom_nodes (ComfyUI would load the whole checkout as a node),
93
204
  // check out the pin, copy the subdirectory, record the source.
94
- const sub = String(src.subdirectory);
95
- if (path.isAbsolute(sub) || sub.split(/[\\/]/).includes('..')) {
96
- return { status: 'blocked', reason: `bad subdirectory ${JSON.stringify(sub)} for ${dep.id}` };
97
- }
98
- if (!src.commit) {
99
- return { status: 'blocked', reason: `${dep.id}: a subdirectory source needs a pinned commit` };
100
- }
101
- const staging = path.join(root, '.animastor-node-sources', dirName);
102
- io.fs.rmSync(staging, { recursive: true, force: true });
103
- io.fs.mkdirSync(path.dirname(staging), { recursive: true });
104
- let c = io.exec('git', ['clone', src.repository, staging]);
105
- if (c.code !== 0) {
106
- io.fs.rmSync(staging, { recursive: true, force: true });
107
- return { status: 'failed', reason: `git clone ${src.repository} failed: ${String(c.stderr || c.error).slice(-300)}` };
108
- }
109
- c = io.exec('git', ['-C', staging, 'checkout', src.commit]);
110
- if (c.code !== 0) {
111
- io.fs.rmSync(staging, { recursive: true, force: true });
112
- return { status: 'failed', reason: `git checkout ${src.commit} failed: ${String(c.stderr).slice(-300)}` };
113
- }
114
- const from = path.join(staging, sub);
115
- if (!io.fs.isDirectory(from)) {
116
- io.fs.rmSync(staging, { recursive: true, force: true });
117
- return { status: 'failed', reason: `subdirectory ${sub} not found in ${src.repository}@${src.commit}` };
118
- }
119
- c = io.exec('cp', ['-a', from, target]);
120
- io.fs.rmSync(staging, { recursive: true, force: true });
121
- if (c.code !== 0) return { status: 'failed', reason: `copy of ${sub} failed: ${String(c.stderr || c.error).slice(-300)}` };
122
- io.fs.writeFileSync(path.join(target, SOURCE_MARKER), JSON.stringify({ repository: src.repository, commit: src.commit, subdirectory: sub }, null, 2) + '\n');
205
+ const staged = copySubdirectory(io, { root, dep, dirName, src, dest: target });
206
+ if (staged) return staged;
123
207
  } else {
124
208
  let r = io.exec('git', ['clone', src.repository, target]);
125
209
  if (r.code !== 0) {
@@ -169,6 +253,15 @@ function installCustomNodes(io, { root, manifests, planStep, python = null, torc
169
253
  ...installCustomNode(io, { root, dep, python, torchSpec, retryDeps: retryDeps.includes(item.id), log }),
170
254
  });
171
255
  }
256
+ // 0.2.15: installer-copied nodes behind the manifest pin (resolver action 'update')
257
+ for (const item of planStep.update || []) {
258
+ const dep = findManifestDep(manifests, item.id);
259
+ if (!dep) {
260
+ results.push({ id: item.id, status: 'blocked', reason: 'not found in any manifest' });
261
+ continue;
262
+ }
263
+ results.push({ id: item.id, ...updateCustomNode(io, { root, dep, python, torchSpec, log }) });
264
+ }
172
265
  for (const item of planStep.review || []) {
173
266
  results.push({
174
267
  id: item.id,
@@ -181,5 +274,6 @@ function installCustomNodes(io, { root, manifests, planStep, python = null, torc
181
274
 
182
275
  module.exports = {
183
276
  installCustomNode,
277
+ updateCustomNode,
184
278
  installCustomNodes,
185
279
  };
@@ -94,7 +94,7 @@ function gitInfo(io, dir) {
94
94
  if (!io.fs.existsSync(marker)) return null;
95
95
  try {
96
96
  const m = JSON.parse(io.fs.readFileSync(marker, 'utf8'));
97
- if (m && typeof m.repository === 'string' && typeof m.commit === 'string') return { repository: m.repository, commit: m.commit, tag: null };
97
+ if (m && typeof m.repository === 'string' && typeof m.commit === 'string') return { repository: m.repository, commit: m.commit, tag: null, animastor_source: true };
98
98
  } catch (_) { /* unreadable marker → plain directory */ }
99
99
  return null;
100
100
  }
@@ -310,6 +310,9 @@ function probeCustomNodes(io, root) {
310
310
  repository: git ? git.repository : null,
311
311
  commit: git ? git.commit : null,
312
312
  is_git: git !== null,
313
+ // 0.2.15: copied by the installer from a repository subdirectory
314
+ // (.animastor-source.json) — the installer may update it to the pin
315
+ ...(git && git.animastor_source ? { animastor_source: true } : {}),
313
316
  });
314
317
  }
315
318
  return out;
@@ -255,6 +255,10 @@ function buildArtifactStep({ id, title, report, kinds, decisionKey, decisions, m
255
255
  kind: 'prompt',
256
256
  missing: missing.map((e) => ({ id: e.id, label: entryLabel(e) })),
257
257
  review: review.map((e) => ({ id: e.id, label: entryLabel(e), reason: e.reason || e.status, notes: e.notes || [] })),
258
+ // 0.2.15: installer-copied nodes behind the manifest pin — updated
259
+ // without a question (the engine runs them even when the step is a noop)
260
+ update: report.entries.filter((e) => kinds.includes(e.kind) && e.action === 'update')
261
+ .map((e) => ({ id: e.id, label: entryLabel(e), from: e.found ? e.found.commit : null, to: e.expected || null })),
258
262
  ...(stepExtra || {}),
259
263
  };
260
264
  if (missing.length === 0) {
@@ -730,6 +734,7 @@ function renderPlanText(plan, report, { questions = true, header = true } = {})
730
734
  const actions = toInstall.filter((e) => !declined.has(e.id)).map(actionLine);
731
735
  for (const e of report.entries) {
732
736
  if (e.action === 'configure') actions.push(`Configure ${entryLabel(e)} (.env)`);
737
+ if (e.action === 'update') actions.push(`Update ${entryLabel(e)}: ${String((e.found && e.found.commit) || '?').slice(0, 7)} → ${String(e.expected || '?').slice(0, 7)}`);
733
738
  }
734
739
  if (actions.length > 0) {
735
740
  lines.push('Actions:');
@@ -1137,6 +1137,7 @@ function mapEntryToAction(entry, { mode, downloadSpecs }) {
1137
1137
  return { ...base, type: 'REVIEW', component: 'runtime', name: RUNTIME_LABELS[entry.component] || entry.component };
1138
1138
  }
1139
1139
  case 'custom_node': {
1140
+ if (entry.action === 'update') return { ...base, type: 'INSTALL', component: 'custom-node', name: entry.name || entry.id, update: true };
1140
1141
  if (entry.status === 'installed') return { ...base, type: 'KEEP', component: 'custom-node', name: entry.name || entry.id };
1141
1142
  if (entry.requirement !== 'required') return null; // optional/unknown extras are never auto-installed
1142
1143
  return { ...base, type: 'INSTALL', component: 'custom-node', name: entry.name || entry.id };