home-hosted 0.9.9 → 0.9.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -2249,6 +2249,46 @@ function writeFileAtomic(file, content, options = {}) {
2249
2249
  }
2250
2250
  var init_atomic = __esmMin((() => {}));
2251
2251
  //#endregion
2252
+ //#region src/helpers/config-text.ts
2253
+ /**
2254
+ * Decodes a hand-editable state file the way the editors that write them save it.
2255
+ *
2256
+ * Every file the panel invites a person to hand-edit is JSON, and `JSON.parse` refuses a
2257
+ * **byte-order mark**: PowerShell's `Set-Content -Encoding UTF8` (5.1) and `Out-File`/`>`
2258
+ * (UTF-16LE) both prepend one, and Notepad writes one for a "UTF-8 with BOM" save. The
2259
+ * refusal is a parse error naming an invisible character — `Unexpected token '\uFEFF'` — so the
2260
+ * person is told their JSON is broken when it is not, and is invited to
2261
+ * fix a file the editor will re-encode identically on the next save.
2262
+ *
2263
+ * Stripping the mark is not a silent coercion: a BOM is not content, and a file whose real
2264
+ * content is unchanged parses to the same object with or without it. UTF-16 is decoded rather
2265
+ * than refused because that is what `>` produces on Windows, and it is recognisable from its
2266
+ * own prefix — a wrong guess would still fail loudly on `JSON.parse`.
2267
+ *
2268
+ * Read as a `Buffer`, never with `'utf8'`: a `'utf8'` read of UTF-16LE text has already lost
2269
+ * the information this needs to tell them apart.
2270
+ */
2271
+ function decodeStateFile(bytes) {
2272
+ if (bytes.length >= 2) {
2273
+ if (bytes[0] === 255 && bytes[1] === 254) return stripBom(bytes.subarray(2).toString("utf16le"));
2274
+ if (bytes[0] === 254 && bytes[1] === 255) {
2275
+ const swapped = Buffer$1.from(bytes.subarray(2));
2276
+ swapped.swap16();
2277
+ return stripBom(swapped.toString("utf16le"));
2278
+ }
2279
+ }
2280
+ return stripBom(bytes.toString("utf8"));
2281
+ }
2282
+ /** A UTF-8 BOM is three bytes; Node decodes it to the one `\uFEFF` character. */
2283
+ function stripBom(text) {
2284
+ return text.charCodeAt(0) === 65279 ? text.slice(1) : text;
2285
+ }
2286
+ /** `decodeStateFile` for a path. Missing files still throw `ENOENT`, as a caller expects. */
2287
+ function readStateFile(file) {
2288
+ return decodeStateFile(fs.readFileSync(file));
2289
+ }
2290
+ var init_config_text = __esmMin((() => {}));
2291
+ //#endregion
2252
2292
  //#region src/shared/shape.ts
2253
2293
  /**
2254
2294
  * A plain object, and nothing else: not `null`, and not an array.
@@ -2431,6 +2471,7 @@ function openDdns(accountId, sealed, key) {
2431
2471
  var COST, KEYLEN, SALT_BYTES, LEGACY_TELEGRAM_ID, DDNS_KEYLEN, DDNS_IV_BYTES, DDNS_AAD_PREFIX, DDNS_SEALED_ALGO, API_TOKEN_BYTES, API_TOKEN_HINT_CHARS, SecretsStore;
2432
2472
  var init_secrets = __esmMin((() => {
2433
2473
  init_atomic();
2474
+ init_config_text();
2434
2475
  init_logger();
2435
2476
  init_error_message();
2436
2477
  init_shape();
@@ -2693,7 +2734,7 @@ var init_secrets = __esmMin((() => {
2693
2734
  if (!fs.existsSync(this.file)) return this.inScope(empty);
2694
2735
  let text;
2695
2736
  try {
2696
- text = fs.readFileSync(this.file, "utf8");
2737
+ text = readStateFile(this.file);
2697
2738
  } catch (error) {
2698
2739
  this.error = `cannot read ${this.file}: ${errorMessage(error)}`;
2699
2740
  return this.inScope(empty);
@@ -3987,6 +4028,7 @@ var workspacesFileSchema, WorkspaceError, seed, WorkspaceRegistry;
3987
4028
  var init_workspaces = __esmMin((() => {
3988
4029
  init_schema();
3989
4030
  init_atomic();
4031
+ init_config_text();
3990
4032
  init_paths();
3991
4033
  init_version();
3992
4034
  init_contracts();
@@ -4042,7 +4084,7 @@ var init_workspaces = __esmMin((() => {
4042
4084
  load() {
4043
4085
  let parsed;
4044
4086
  try {
4045
- parsed = JSON.parse(fs.readFileSync(this.file, "utf8"));
4087
+ parsed = JSON.parse(readStateFile(this.file));
4046
4088
  } catch (error) {
4047
4089
  if (error.code === "ENOENT") {
4048
4090
  this.commit(seed());
@@ -4840,6 +4882,7 @@ var init_settings$1 = __esmMin((() => {
4840
4882
  init_schema();
4841
4883
  init_seed();
4842
4884
  init_atomic();
4885
+ init_config_text();
4843
4886
  init_paths();
4844
4887
  ConfigError = class extends Error {
4845
4888
  name = "ConfigError";
@@ -4915,7 +4958,7 @@ var init_settings$1 = __esmMin((() => {
4915
4958
  reloadFromDisk() {
4916
4959
  let text;
4917
4960
  try {
4918
- text = fs.readFileSync(this.file, "utf8");
4961
+ text = readStateFile(this.file);
4919
4962
  } catch {
4920
4963
  this.error = `${path.basename(this.file)} is gone`;
4921
4964
  return {
@@ -4956,7 +4999,7 @@ var init_settings$1 = __esmMin((() => {
4956
4999
  let text;
4957
5000
  let parsed;
4958
5001
  try {
4959
- text = fs.readFileSync(this.file, "utf8");
5002
+ text = readStateFile(this.file);
4960
5003
  parsed = JSON.parse(text);
4961
5004
  } catch (error) {
4962
5005
  this.error = `cannot parse ${path.basename(this.file)}: ${error.message}`;
@@ -6729,7 +6772,7 @@ var init_webhook = __esmMin((() => {
6729
6772
  function readFile(file) {
6730
6773
  let text;
6731
6774
  try {
6732
- text = fs.readFileSync(file, "utf8");
6775
+ text = readStateFile(file);
6733
6776
  } catch (error) {
6734
6777
  if (error.code === "ENOENT") return {
6735
6778
  text: null,
@@ -6769,6 +6812,7 @@ var init_store = __esmMin((() => {
6769
6812
  init_seed();
6770
6813
  init_settings$1();
6771
6814
  init_atomic();
6815
+ init_config_text();
6772
6816
  init_ddns$2();
6773
6817
  init_webhook();
6774
6818
  init_contracts();
@@ -6838,8 +6882,26 @@ var init_store = __esmMin((() => {
6838
6882
  get configSchemaVersion() {
6839
6883
  return Math.max(this.settingsSchemaVersion, this.serversSchemaVersion);
6840
6884
  }
6885
+ /**
6886
+ * The steps a workspace's files need, counting **both** sides.
6887
+ *
6888
+ * The two files are stamped independently — a person may hand-write `servers.config.json`
6889
+ * (which is unstamped, and so reads as schema 1) beside a `settings.json` the panel wrote at
6890
+ * the current schema. `configSchemaVersion` answers `max()` because that is the shape *this
6891
+ * release* understands of the pair, but the migrations that have to run belong to the **older**
6892
+ * file: `planConfigMigrations` is monotonic, so the lower version is the one with steps.
6893
+ * Reading `max()` here reported *no* pending migration while the reader was refusing the file
6894
+ * for needing one, which left the startup branch that says `run migrate` unreachable and sent
6895
+ * the person to "fix or install" instead.
6896
+ *
6897
+ * A file that cannot be **parsed** is not a migration candidate, though: a schema number can only
6898
+ * be read from a file that is JSON, and `migrate` refuses one it cannot read rather than lifting
6899
+ * it. The startup guard prints this list as "run migrate", so a broken file must not appear
6900
+ * here — it belongs in `configError`'s "fix …" advice alone.
6901
+ */
6841
6902
  get pendingMigrations() {
6842
- return planConfigMigrations(this.configSchemaVersion).steps;
6903
+ if (this.settingsParseError !== null || this.serversParseError !== null) return [];
6904
+ return planConfigMigrations(Math.min(this.settingsSchemaVersion, this.serversSchemaVersion)).steps;
6843
6905
  }
6844
6906
  onChange(listener) {
6845
6907
  this.listeners.add(listener);
@@ -8753,6 +8815,176 @@ var init_port = __esmMin((() => {
8753
8815
  FILETIME_UNIX_OFFSET_MS = 0xa9730b66800;
8754
8816
  }));
8755
8817
  //#endregion
8818
+ //#region src/providers/process.ts
8819
+ /**
8820
+ * Resolves a bare command through the entry's own directory and the project's
8821
+ * `node_modules/.bin` first, so a server installed as a project dependency is
8822
+ * found even when the launcher's PATH has no pnpm-injected bin dir.
8823
+ */
8824
+ function resolveCommand(command, ...searchDirs) {
8825
+ if (command.includes("/") || command.includes("\\")) return command;
8826
+ const candidates = process.platform === "win32" && path.extname(command) === "" ? WINDOWS_SHIM_EXTENSIONS.map((extension) => `${command}${extension}`) : [command];
8827
+ for (const dir of searchDirs) for (const candidate of candidates) {
8828
+ const local = path.join(dir, "node_modules", ".bin", candidate);
8829
+ if (fs.existsSync(local)) return local;
8830
+ }
8831
+ return command;
8832
+ }
8833
+ /**
8834
+ * Does this program exist where `spawn` would look it up, and where?
8835
+ *
8836
+ * Used only to tell a **pasted command line** apart from a missing program: `spawn` answers both
8837
+ * with the same `ENOENT`, and the two have opposite fixes. `null` means it was not found anywhere
8838
+ * this process would search.
8839
+ *
8840
+ * A bare name is searched on `PATH` (plus `.exe`/`.cmd`/`.bat` on Windows, because that is what
8841
+ * the OS appends); anything with a separator is a path and is stat'd as written.
8842
+ */
8843
+ function findProgram(command, cwd = projectDir) {
8844
+ if (command.includes("/") || command.includes("\\")) {
8845
+ const resolved = path.resolve(cwd, command);
8846
+ return isExecutable(resolved) ? resolved : null;
8847
+ }
8848
+ const extensions = process.platform === "win32" ? ["", ...WINDOWS_SHIM_EXTENSIONS] : [""];
8849
+ const dirs = (process.env.PATH ?? "").split(path.delimiter).filter((dir) => dir.length > 0);
8850
+ for (const dir of dirs) for (const extension of extensions) {
8851
+ const candidate = path.join(dir, `${command}${extension}`);
8852
+ if (isExecutable(candidate)) return candidate;
8853
+ }
8854
+ return null;
8855
+ }
8856
+ /** A file this user may run. A directory named like a program is not one. */
8857
+ function isExecutable(file) {
8858
+ try {
8859
+ if (!fs.statSync(file).isFile()) return false;
8860
+ if (process.platform === "win32") return true;
8861
+ fs.accessSync(file, fs.constants.X_OK);
8862
+ return true;
8863
+ } catch {
8864
+ return false;
8865
+ }
8866
+ }
8867
+ /** Relative entry paths belong to the project that launched the panel. */
8868
+ function resolveCwd(cwd, base = projectDir) {
8869
+ return path.resolve(base, cwd);
8870
+ }
8871
+ /** Node cannot spawn a Windows `.cmd`/`.bat` shim without a shell (EINVAL). */
8872
+ function needsShell(command) {
8873
+ return process.platform === "win32" && /\.(?:cmd|bat)$/i.test(command);
8874
+ }
8875
+ function spawnManaged(spec, options = {}) {
8876
+ return spawn(spec.command, spec.args, {
8877
+ cwd: spec.cwd,
8878
+ env: {
8879
+ ...process.env,
8880
+ ...spec.env
8881
+ },
8882
+ detached: options.detached ?? true,
8883
+ stdio: [
8884
+ "ignore",
8885
+ "pipe",
8886
+ "pipe"
8887
+ ],
8888
+ shell: needsShell(spec.command),
8889
+ windowsHide: true
8890
+ });
8891
+ }
8892
+ /** SIGTERM (default) to the child, escalating to SIGKILL after the grace period. */
8893
+ async function terminate(child, options) {
8894
+ if (child.exitCode !== null || child.signalCode !== null) return "exited";
8895
+ const exited = waitForExit$1(child, options.graceMs);
8896
+ signalChild(child, options.signal, options.killGroup);
8897
+ if (await exited) return "exited";
8898
+ signalChild(child, "SIGKILL", options.killGroup);
8899
+ await waitForExit$1(child, 2e3);
8900
+ return "force-killed";
8901
+ }
8902
+ /**
8903
+ * Windows has no process groups and no SIGTERM: `taskkill /T` walks the tree and
8904
+ * `/F` is the only reliable way to stop a console process.
8905
+ */
8906
+ async function killTreeWindows(pid) {
8907
+ try {
8908
+ await execFileAsync$1("taskkill", [
8909
+ "/pid",
8910
+ String(pid),
8911
+ "/T",
8912
+ "/F"
8913
+ ], { timeout: 5e3 });
8914
+ } catch {}
8915
+ }
8916
+ function signalChild(child, signal, killGroup) {
8917
+ const pid = child.pid;
8918
+ if (pid === void 0) return;
8919
+ signalPid(pid, signal, killGroup);
8920
+ }
8921
+ function signalPid(pid, signal, killGroup) {
8922
+ if (process.platform === "win32") {
8923
+ if (killGroup) killTreeWindows(pid);
8924
+ else try {
8925
+ process.kill(pid, signal);
8926
+ } catch {}
8927
+ return;
8928
+ }
8929
+ if (killGroup) try {
8930
+ process.kill(-pid, signal);
8931
+ return;
8932
+ } catch {}
8933
+ try {
8934
+ process.kill(pid, signal);
8935
+ } catch {}
8936
+ }
8937
+ /**
8938
+ * The same shutdown a supervised child gets, for a process we adopted instead of
8939
+ * spawned: a detached successor is not our child, so it is signalled by pid (and
8940
+ * by process group when asked) and its exit is polled rather than awaited.
8941
+ *
8942
+ * Liveness comes from `isProcessAlive`, never a local signal-0 copy: a second definition returned
8943
+ * `false` for `EPERM`, so a process that was there but not ours to signal read as "exited" and
8944
+ * `'force-killed'` was returned for one still running. One predicate, one answer.
8945
+ */
8946
+ async function terminatePid(pid, options) {
8947
+ if (!isProcessAlive(pid)) return "exited";
8948
+ signalPid(pid, options.signal, options.killGroup);
8949
+ const deadline = Date.now() + Math.max(0, options.graceMs);
8950
+ while (Date.now() < deadline && isProcessAlive(pid)) await delay$1(50);
8951
+ if (!isProcessAlive(pid)) return "exited";
8952
+ signalPid(pid, "SIGKILL", options.killGroup);
8953
+ const hardDeadline = Date.now() + 2e3;
8954
+ while (Date.now() < hardDeadline && isProcessAlive(pid)) await delay$1(50);
8955
+ return "force-killed";
8956
+ }
8957
+ function delay$1(ms) {
8958
+ return new Promise((resolve) => setTimeout(resolve, ms));
8959
+ }
8960
+ function waitForExit$1(child, timeoutMs) {
8961
+ if (child.exitCode !== null || child.signalCode !== null) return Promise.resolve(true);
8962
+ if (timeoutMs <= 0) return Promise.resolve(false);
8963
+ return new Promise((resolve) => {
8964
+ const timer = setTimeout(() => {
8965
+ child.removeListener("exit", onExit);
8966
+ resolve(false);
8967
+ }, timeoutMs);
8968
+ function onExit() {
8969
+ clearTimeout(timer);
8970
+ resolve(true);
8971
+ }
8972
+ child.once("exit", onExit);
8973
+ });
8974
+ }
8975
+ var execFileAsync$1, WINDOWS_SHIM_EXTENSIONS;
8976
+ var init_process = __esmMin((() => {
8977
+ init_paths();
8978
+ init_port();
8979
+ execFileAsync$1 = promisify(execFile);
8980
+ WINDOWS_SHIM_EXTENSIONS = [
8981
+ ".exe",
8982
+ ".cmd",
8983
+ ".bat",
8984
+ ".ps1"
8985
+ ];
8986
+ }));
8987
+ //#endregion
8756
8988
  //#region src/providers/nanny.ts
8757
8989
  var nanny_exports$2 = /* @__PURE__ */ __exportAll({
8758
8990
  HEARTBEAT_STALE_MS: () => HEARTBEAT_STALE_MS,
@@ -8882,12 +9114,54 @@ function exitCodeHint(code) {
8882
9114
  *
8883
9115
  * `command` is the configured program, so the two cases can be told apart: if a bare name has no
8884
9116
  * path separator, the shell would have searched `PATH` and this one did not.
9117
+ *
9118
+ * A **missing working directory** is the third cause of the same errno, and it is the one a
9119
+ * deployment hits: `spawn` resolves `cwd` before it looks for the program, so an entry whose `cwd`
9120
+ * does not exist *under this launch directory* fails exactly like an uninstalled program. That read
9121
+ * sent a person to `which node` while `node` was fine and only the relative path was wrong (a unit
9122
+ * file with no `WorkingDirectory=`, a container started from `/`). `cwd` is therefore checked first:
9123
+ * if it is not an existing directory, nothing else about the spawn could have worked.
8885
9124
  */
8886
- function describeSpawnError(error, command) {
8887
- if (error.code === "ENOENT") return command.includes("/") || command.includes("\\") ? `\`${command}\` does not exist — check the path, and any directory on the way to it` : `\`${command}\` was not found — is it installed, and is it on PATH for the user running the panel?`;
9125
+ function describeSpawnError(error, command, cwd) {
9126
+ const missingDir = cwd === void 0 ? null : describeMissingDir(cwd);
9127
+ if (missingDir !== null && (error.code === "ENOENT" || error.code === "ENOTDIR")) return missingDir;
9128
+ if (error.code === "ENOENT") {
9129
+ const pasted = describePastedCommandLine(command, cwd);
9130
+ if (pasted !== null) return pasted;
9131
+ return command.includes("/") || command.includes("\\") ? `\`${command}\` does not exist — check the path, and any directory on the way to it` : `\`${command}\` was not found — is it installed, and is it on PATH for the user running the panel?`;
9132
+ }
8888
9133
  if (error.code === "EACCES") return `\`${command}\` exists but is not executable — check its permissions (chmod +x)`;
8889
9134
  return `${error.message} (while running \`${command}\`)`;
8890
9135
  }
9136
+ /**
9137
+ * The first mistake the Add-server form invites: a whole command line typed into `Command`.
9138
+ *
9139
+ * `Command` is spawned **without a shell** and `Arguments` is a separate field, so `node server.js`
9140
+ * names a program called `node server.js`. The fix is to split it — and the sentence has to say so,
9141
+ * because the alternative reading ("node is not installed") is what sends someone to `which node`
9142
+ * while `node` is right there.
9143
+ *
9144
+ * Only claimed when the evidence is unambiguous: the field has whitespace, and the program it opens
9145
+ * with **does** resolve. So a genuinely missing program keeps the message about PATH, and a path with
9146
+ * a space in it is never split (it has no bare first word that resolves). See `findProgram`.
9147
+ */
9148
+ function describePastedCommandLine(command, cwd) {
9149
+ const words = command.trim().split(/\s+/);
9150
+ if (words.length < 2) return null;
9151
+ const program = words[0];
9152
+ if (findProgram(program, cwd) === null) return null;
9153
+ return `\`${command}\` is a whole command line, but \`Command\` is spawned without a shell — this release looks for a program named \`${command}\`. Put \`${program}\` in \`Command\` and the rest in \`Arguments\`, one argument per line`;
9154
+ }
9155
+ /** Why a working directory cannot be used, in one sentence, or null when it can. */
9156
+ function describeMissingDir(cwd) {
9157
+ try {
9158
+ if (fs.statSync(cwd).isDirectory()) return null;
9159
+ return `the working directory \`${cwd}\` is not a directory — a relative \`cwd\` resolves against the directory the panel was started from`;
9160
+ } catch (error) {
9161
+ if (error.code === "ENOENT") return `the working directory \`${cwd}\` does not exist — a relative \`cwd\` resolves against the directory the panel was started from, so a service started from elsewhere (systemd, docker, a login shell) looks in a different place`;
9162
+ return `the working directory \`${cwd}\` cannot be read — check its permissions`;
9163
+ }
9164
+ }
8891
9165
  /** `SIGKILL` for 9, or null when the number names nothing. */
8892
9166
  function signalName(number) {
8893
9167
  for (const [name, value] of Object.entries(os.constants.signals)) if (value === number) return name;
@@ -8913,6 +9187,7 @@ var init_nanny$2 = __esmMin((() => {
8913
9187
  init_identity();
8914
9188
  init_port();
8915
9189
  init_proc();
9190
+ init_process();
8916
9191
  init_contracts();
8917
9192
  SPEC_MODE = 384;
8918
9193
  SPEC_SUFFIX = ".spec.json";
@@ -13228,142 +13503,6 @@ var init_archive = __esmMin((() => {
13228
13503
  ];
13229
13504
  }));
13230
13505
  //#endregion
13231
- //#region src/providers/process.ts
13232
- /**
13233
- * Resolves a bare command through the entry's own directory and the project's
13234
- * `node_modules/.bin` first, so a server installed as a project dependency is
13235
- * found even when the launcher's PATH has no pnpm-injected bin dir.
13236
- */
13237
- function resolveCommand(command, ...searchDirs) {
13238
- if (command.includes("/") || command.includes("\\")) return command;
13239
- const candidates = process.platform === "win32" && path.extname(command) === "" ? [command, ...WINDOWS_SHIM_EXTENSIONS.map((extension) => `${command}${extension}`)] : [command];
13240
- for (const dir of searchDirs) for (const candidate of candidates) {
13241
- const local = path.join(dir, "node_modules", ".bin", candidate);
13242
- if (fs.existsSync(local)) return local;
13243
- }
13244
- return command;
13245
- }
13246
- /** Relative entry paths belong to the project that launched the panel. */
13247
- function resolveCwd(cwd, base = projectDir) {
13248
- return path.resolve(base, cwd);
13249
- }
13250
- /** Node cannot spawn a Windows `.cmd`/`.bat` shim without a shell (EINVAL). */
13251
- function needsShell(command) {
13252
- return process.platform === "win32" && /\.(?:cmd|bat)$/i.test(command);
13253
- }
13254
- function spawnManaged(spec, options = {}) {
13255
- return spawn(spec.command, spec.args, {
13256
- cwd: spec.cwd,
13257
- env: {
13258
- ...process.env,
13259
- ...spec.env
13260
- },
13261
- detached: options.detached ?? true,
13262
- stdio: [
13263
- "ignore",
13264
- "pipe",
13265
- "pipe"
13266
- ],
13267
- shell: needsShell(spec.command),
13268
- windowsHide: true
13269
- });
13270
- }
13271
- /** SIGTERM (default) to the child, escalating to SIGKILL after the grace period. */
13272
- async function terminate(child, options) {
13273
- if (child.exitCode !== null || child.signalCode !== null) return "exited";
13274
- const exited = waitForExit$1(child, options.graceMs);
13275
- signalChild(child, options.signal, options.killGroup);
13276
- if (await exited) return "exited";
13277
- signalChild(child, "SIGKILL", options.killGroup);
13278
- await waitForExit$1(child, 2e3);
13279
- return "force-killed";
13280
- }
13281
- /**
13282
- * Windows has no process groups and no SIGTERM: `taskkill /T` walks the tree and
13283
- * `/F` is the only reliable way to stop a console process.
13284
- */
13285
- async function killTreeWindows(pid) {
13286
- try {
13287
- await execFileAsync$1("taskkill", [
13288
- "/pid",
13289
- String(pid),
13290
- "/T",
13291
- "/F"
13292
- ], { timeout: 5e3 });
13293
- } catch {}
13294
- }
13295
- function signalChild(child, signal, killGroup) {
13296
- const pid = child.pid;
13297
- if (pid === void 0) return;
13298
- signalPid(pid, signal, killGroup);
13299
- }
13300
- function signalPid(pid, signal, killGroup) {
13301
- if (process.platform === "win32") {
13302
- if (killGroup) killTreeWindows(pid);
13303
- else try {
13304
- process.kill(pid, signal);
13305
- } catch {}
13306
- return;
13307
- }
13308
- if (killGroup) try {
13309
- process.kill(-pid, signal);
13310
- return;
13311
- } catch {}
13312
- try {
13313
- process.kill(pid, signal);
13314
- } catch {}
13315
- }
13316
- /**
13317
- * The same shutdown a supervised child gets, for a process we adopted instead of
13318
- * spawned: a detached successor is not our child, so it is signalled by pid (and
13319
- * by process group when asked) and its exit is polled rather than awaited.
13320
- *
13321
- * Liveness comes from `isProcessAlive`, never a local signal-0 copy: a second definition returned
13322
- * `false` for `EPERM`, so a process that was there but not ours to signal read as "exited" and
13323
- * `'force-killed'` was returned for one still running. One predicate, one answer.
13324
- */
13325
- async function terminatePid(pid, options) {
13326
- if (!isProcessAlive(pid)) return "exited";
13327
- signalPid(pid, options.signal, options.killGroup);
13328
- const deadline = Date.now() + Math.max(0, options.graceMs);
13329
- while (Date.now() < deadline && isProcessAlive(pid)) await delay$1(50);
13330
- if (!isProcessAlive(pid)) return "exited";
13331
- signalPid(pid, "SIGKILL", options.killGroup);
13332
- const hardDeadline = Date.now() + 2e3;
13333
- while (Date.now() < hardDeadline && isProcessAlive(pid)) await delay$1(50);
13334
- return "force-killed";
13335
- }
13336
- function delay$1(ms) {
13337
- return new Promise((resolve) => setTimeout(resolve, ms));
13338
- }
13339
- function waitForExit$1(child, timeoutMs) {
13340
- if (child.exitCode !== null || child.signalCode !== null) return Promise.resolve(true);
13341
- if (timeoutMs <= 0) return Promise.resolve(false);
13342
- return new Promise((resolve) => {
13343
- const timer = setTimeout(() => {
13344
- child.removeListener("exit", onExit);
13345
- resolve(false);
13346
- }, timeoutMs);
13347
- function onExit() {
13348
- clearTimeout(timer);
13349
- resolve(true);
13350
- }
13351
- child.once("exit", onExit);
13352
- });
13353
- }
13354
- var execFileAsync$1, WINDOWS_SHIM_EXTENSIONS;
13355
- var init_process = __esmMin((() => {
13356
- init_paths();
13357
- init_port();
13358
- execFileAsync$1 = promisify(execFile);
13359
- WINDOWS_SHIM_EXTENSIONS = [
13360
- ".cmd",
13361
- ".exe",
13362
- ".bat",
13363
- ".ps1"
13364
- ];
13365
- }));
13366
- //#endregion
13367
13506
  //#region src/helpers/backoff.ts
13368
13507
  /** Exponential backoff: base * factor^(attempt - 1), capped at maxDelayMs. */
13369
13508
  function computeBackoff(attempt, options) {
@@ -14991,7 +15130,7 @@ var init_supervisor = __esmMin((() => {
14991
15130
  const stderr = new LineSplitter((stream, text) => this.log(entry, stream, text));
14992
15131
  child.stdout?.on("data", (chunk) => stdout.push("stdout", chunk));
14993
15132
  child.stderr?.on("data", (chunk) => stderr.push("stderr", chunk));
14994
- this.attachChild(entry, child, `${command} ${args.join(" ")}`.trim(), () => {
15133
+ this.attachChild(entry, child, `${command} ${args.join(" ")}`.trim(), cwd, () => {
14995
15134
  stdout.flush("stdout");
14996
15135
  stderr.flush("stderr");
14997
15136
  });
@@ -15045,7 +15184,7 @@ var init_supervisor = __esmMin((() => {
15045
15184
  return this.failSpawn(entry, error.message);
15046
15185
  }
15047
15186
  child.unref();
15048
- this.attachChild(entry, child, `nanny → ${command} ${args.join(" ")}`.trim());
15187
+ this.attachChild(entry, child, `nanny → ${command} ${args.join(" ")}`.trim(), cwd);
15049
15188
  this.followPersistent(entry);
15050
15189
  return { ok: true };
15051
15190
  }
@@ -15059,8 +15198,14 @@ var init_supervisor = __esmMin((() => {
15059
15198
  error: message
15060
15199
  };
15061
15200
  }
15062
- /** The bookkeeping every spawn shares, plus the exit events that end it. */
15063
- attachChild(entry, child, detail, flush) {
15201
+ /**
15202
+ * The bookkeeping every spawn shares, plus the exit events that end it.
15203
+ *
15204
+ * `cwd` is the directory the child was spawned in. A spawn that fails with `ENOENT` may have
15205
+ * failed because the *working directory* is missing rather than the program — `spawn` resolves
15206
+ * one before it looks for the other — so `describeSpawnError` needs it to name the real cause.
15207
+ */
15208
+ attachChild(entry, child, detail, cwd, flush) {
15064
15209
  entry.child = child;
15065
15210
  entry.pid = child.pid ?? null;
15066
15211
  entry.startedAt = Date.now();
@@ -15084,7 +15229,7 @@ var init_supervisor = __esmMin((() => {
15084
15229
  entry.unhealthySince = null;
15085
15230
  this.publishServer(entry);
15086
15231
  child.once("error", (error) => {
15087
- entry.lastError = describeSpawnError(error, entry.config.command);
15232
+ entry.lastError = describeSpawnError(error, entry.config.command, cwd);
15088
15233
  this.log(entry, "system", `process error: ${entry.lastError}`);
15089
15234
  flush?.();
15090
15235
  this.handleExit(entry, child, null, null);
@@ -19929,16 +20074,16 @@ async function runControlPlane(options) {
19929
20074
  const settings = new GlobalSettingsStore();
19930
20075
  settings.load();
19931
20076
  settings.writeJsonSchema();
19932
- if (settings.configError !== null) {
19933
- logger.error(`refusing to start: ${settings.configError}`);
19934
- logger.info(`fix ${settings.path}, or install the release that wrote it`);
19935
- process.exit(1);
19936
- }
19937
20077
  if (settings.pendingMigrations.length > 0) {
19938
20078
  logger.error(`refusing to start: ${settings.path} needs ${settings.pendingMigrations.length} migration(s) before ${appVersion()} can use it`);
19939
20079
  logger.info("run `home-hosted migrate` to see and apply them");
19940
20080
  process.exit(1);
19941
20081
  }
20082
+ if (settings.configError !== null) {
20083
+ logger.error(`refusing to start: ${settings.configError}`);
20084
+ logger.info(`fix ${settings.path}, or install the release that wrote it`);
20085
+ process.exit(1);
20086
+ }
19942
20087
  const registry = new WorkspaceRegistry();
19943
20088
  registry.load();
19944
20089
  if (registry.configError !== null) {
@@ -20093,6 +20238,11 @@ async function runControlPlane(options) {
20093
20238
  });
20094
20239
  for (const workspace of panel.workspaces()) {
20095
20240
  const store = workspace.store;
20241
+ if (store.pendingMigrations.length > 0) {
20242
+ logger.error(`refusing to start: workspace "${workspace.id}" needs ${store.pendingMigrations.length} migration(s) before ${appVersion()} can use it`);
20243
+ logger.info("run `home-hosted migrate` to see and apply them");
20244
+ process.exit(1);
20245
+ }
20096
20246
  if (store.configError !== null) {
20097
20247
  logger.error(`refusing to start: workspace "${workspace.id}": ${store.configError}`);
20098
20248
  logger.info(`fix ${store.path} and ${store.settingsPath}, or install the release that wrote them`);
@@ -20103,11 +20253,6 @@ async function runControlPlane(options) {
20103
20253
  logger.info("fix or restore the file, or move it aside to start fresh — starting fresh discards it");
20104
20254
  process.exit(1);
20105
20255
  }
20106
- if (store.pendingMigrations.length > 0) {
20107
- logger.error(`refusing to start: workspace "${workspace.id}" needs ${store.pendingMigrations.length} migration(s) before ${appVersion()} can use it`);
20108
- logger.info("run `home-hosted migrate` to see and apply them");
20109
- process.exit(1);
20110
- }
20111
20256
  }
20112
20257
  let shuttingDown = false;
20113
20258
  const shutdown = async (reason) => {
@@ -20985,7 +21130,7 @@ function targets() {
20985
21130
  validate: (raw) => {
20986
21131
  let defaults = {};
20987
21132
  try {
20988
- const settingsRaw = JSON.parse(fs.readFileSync(workspaceSettingsPath(workspace.id), "utf8"));
21133
+ const settingsRaw = JSON.parse(readStateFile(workspaceSettingsPath(workspace.id)));
20989
21134
  const meta = typeof settingsRaw.meta === "object" && settingsRaw.meta !== null ? settingsRaw.meta : {};
20990
21135
  const from = typeof meta.schema === "number" ? meta.schema : 1;
20991
21136
  defaults = (planConfigMigrations(from).steps.length > 0 ? applyConfigMigrations(settingsRaw, from).config : settingsRaw)?.defaults ?? {};
@@ -21004,7 +21149,7 @@ async function runMigrate(dryRun, yes) {
21004
21149
  for (const target of existing) {
21005
21150
  let raw;
21006
21151
  try {
21007
- raw = JSON.parse(fs.readFileSync(target.file, "utf8"));
21152
+ raw = JSON.parse(readStateFile(target.file));
21008
21153
  } catch (error) {
21009
21154
  fail(`cannot read ${target.file}: ${errorMessage(error)}`);
21010
21155
  }
@@ -21065,6 +21210,7 @@ var init_migrate = __esmMin((() => {
21065
21210
  init_parse();
21066
21211
  init_workspaces();
21067
21212
  init_atomic();
21213
+ init_config_text();
21068
21214
  init_paths();
21069
21215
  init_version();
21070
21216
  init_error_message();
@@ -21176,6 +21322,23 @@ function detectPackageManager(exists) {
21176
21322
  function runCommand$1(pm, script) {
21177
21323
  return pm === "npm" ? `npm run ${script}` : `${pm} run ${script}`;
21178
21324
  }
21325
+ /**
21326
+ * The `cd` that reaches a scaffolded project, quoted for the shell it will be pasted into.
21327
+ *
21328
+ * The directory is the person's choice, and a space in it is ordinary — `C:\Users\Ann Lee`,
21329
+ * `/srv/my apps`, and the default `./my-servers` all sit under one on some machine. Unquoted,
21330
+ * the line `init` printed as its own "Next:" step was `cd my servers && npm run up`, which the
21331
+ * shell answers `cd: too many arguments` — an error naming a command the person did not
21332
+ * compose, on the one line the scaffold exists to hand them.
21333
+ *
21334
+ * POSIX gets single quotes, with an embedded quote closed and reopened (`'\''`), which is the
21335
+ * one form that is safe inside a single-quoted string. Windows' `cmd.exe` has no single-quote
21336
+ * quoting at all, so it gets double quotes: that is what it understands, and a path whose name
21337
+ * contains a `"` is not representable there either way.
21338
+ */
21339
+ function cdCommand(where) {
21340
+ return `cd ${process.platform === "win32" ? `"${where}"` : `'${where.replace(/'/g, `'\\''`)}'`} && `;
21341
+ }
21179
21342
  /** Install arguments for a scaffolded project (the manifest already lists the dependency). */
21180
21343
  function installArgs(pm) {
21181
21344
  return pm === "yarn" ? [] : ["install"];
@@ -21248,7 +21411,7 @@ async function runInit(options) {
21248
21411
  }
21249
21412
  const relative = path.relative(process.cwd(), target);
21250
21413
  const where = relative.length === 0 || relative.startsWith("..") ? target : relative;
21251
- const cd = relative.length === 0 ? "" : `cd ${where} && `;
21414
+ const cd = relative.length === 0 ? "" : cdCommand(where);
21252
21415
  process.stdout.write(`\nNext:\n`);
21253
21416
  process.stdout.write(` ${bold(`${cd}${runCommand$1(pm, "up")}`)} start the panel (default password \`hh\`)\n`);
21254
21417
  process.stdout.write(` ${dim("then change that password under Settings → Authentication, and add your servers")}\n`);
@@ -22041,11 +22204,18 @@ function filterEntries(entries, scope, exclude) {
22041
22204
  * An id that matches nothing is silently ignored by the service, which is right for an archive that
22042
22205
  * simply does not carry something — and wrong for a typo: `--exclude global:secret` excludes nothing
22043
22206
  * and says nothing, so the archive carries the credentials the person believed they had dropped.
22207
+ *
22208
+ * `action` decides the hint, because the two directions list their ids from different places: a
22209
+ * create plan lists what this host declares, a restore plan lists what the archive holds — and the
22210
+ * command that prints that one is a restore, not a create.
22044
22211
  */
22045
- function assertKnown(ids, entries, flag) {
22212
+ function assertKnown(ids, entries, flag, action) {
22046
22213
  if (ids === void 0) return;
22047
22214
  const unknown = unknownBackupIds(ids, entries);
22048
- if (unknown.length > 0) fail(`${flag} names ${unknown.map((id) => `"${id}"`).join(", ")}, which ${unknown.length === 1 ? "is" : "are"} not in this plan — \`backup create\` with no flags lists the ids`);
22215
+ if (unknown.length > 0) {
22216
+ const hint = action === "create" ? `\`backup create\` with no flags lists the ids` : `\`backup restore <name>\` with no --include/--exclude lists the ids the archive holds`;
22217
+ fail(`${flag} names ${unknown.map((id) => `"${id}"`).join(", ")}, which ${unknown.length === 1 ? "is" : "are"} not in this plan — ${hint}`);
22218
+ }
22049
22219
  }
22050
22220
  /** `--exclude` parsed. An empty value is a mistake, not "exclude nothing". */
22051
22221
  function parseExclude(raw) {
@@ -22202,8 +22372,8 @@ async function runBackupCreate(options) {
22202
22372
  await service.warm();
22203
22373
  return service.view().entries;
22204
22374
  })();
22205
- assertKnown(options.exclude, entries, "--exclude");
22206
- assertKnown(scope.kind === "include" ? scope.ids : void 0, entries, "--include");
22375
+ assertKnown(options.exclude, entries, "--exclude", "create");
22376
+ assertKnown(scope.kind === "include" ? scope.ids : void 0, entries, "--include", "create");
22207
22377
  const wanted = filterEntries(entries, scope, options.exclude);
22208
22378
  if (!options.confirm) {
22209
22379
  if (options.json) {
@@ -22270,6 +22440,32 @@ async function runBackupCreate(options) {
22270
22440
  async function runningEntries() {
22271
22441
  return (await offlineBackup()).runningNow();
22272
22442
  }
22443
+ /**
22444
+ * Why a restore plan is not something to apply, or `null`.
22445
+ *
22446
+ * The service answers a plan for every archive, including ones it refuses to read: `error` carries
22447
+ * the refusal and `items` is empty. A caller that reads only `items` sees a tidy empty restore — and
22448
+ * on a blank host, `restored 0 items` printed with exit 0 is the worst possible answer, because
22449
+ * nothing distinguishes "this archive was empty" from "this archive could not be opened".
22450
+ *
22451
+ * `needsPassword` is its own case: it is the one refusal the person can fix from the same command.
22452
+ */
22453
+ function planRefusal(plan) {
22454
+ if (plan === null) return null;
22455
+ if (plan.needsPassword === true) return `${plan.error ?? "this backup is password-protected"} — add \`--password <text>\` to unlock it`;
22456
+ if (plan.error !== void 0 && plan.error.length > 0) return plan.error;
22457
+ return null;
22458
+ }
22459
+ /**
22460
+ * The plan's refusals and per-item skips, as lines a person can act on.
22461
+ *
22462
+ * `skipped` is the same list the UI draws, and it is the only thing that says a piece of an
22463
+ * otherwise successful restore was left behind — an unreadable `servers.config.json`, a data path
22464
+ * whose declaration changed. Printing only the applied count reported such a restore as complete.
22465
+ */
22466
+ function restoreNotes(plan) {
22467
+ return plan?.skipped ?? [];
22468
+ }
22273
22469
  async function runBackupRestore(options) {
22274
22470
  const scope = options.scope;
22275
22471
  const service = await usesPanel() ? null : (await offlineBackup()).service;
@@ -22277,7 +22473,7 @@ async function runBackupRestore(options) {
22277
22473
  const plan = await (async () => {
22278
22474
  if (service !== null) {
22279
22475
  const archive = service.resolve(options.name);
22280
- if (archive === null) fail(`no backup named "${options.name}" — \`${invocation()} backup list\` shows them`);
22476
+ if (archive === null) fail(`no backup named "${options.name}" in ${service.directory} — a restore takes the archive's file name, not a path; copy it there first (\`${invocation()} backup list\` shows what is there)`);
22281
22477
  return await service.restore(archive, {
22282
22478
  confirm: false,
22283
22479
  password: options.password,
@@ -22287,33 +22483,43 @@ async function runBackupRestore(options) {
22287
22483
  }
22288
22484
  const runtime = await livePanel();
22289
22485
  if (runtime === null) fail(`the control panel is not answering — try again once it is up`);
22290
- const base = new URLSearchParams({ name: options.name });
22291
- if (options.password !== void 0 && options.password.length > 0) base.set("password", options.password);
22292
- if (scope.kind === "include") base.set("include", scope.ids.join(","));
22293
- if (options.exclude !== void 0) base.set("exclude", options.exclude.join(","));
22486
+ const base = restoreQuery(options, scope);
22294
22487
  const answer = await runtime.request(runtime, `/_hh/backups/restore${suffixOf(base)}`, 12e4);
22295
22488
  if (answer === null) fail(`the control panel is not answering at ${runtime.probeUrl}`);
22296
22489
  if (answer.status !== 200) refusal(answer);
22297
22490
  return answer.body;
22298
22491
  })();
22492
+ const refused = planRefusal(plan);
22493
+ if (refused !== null) {
22494
+ if (options.json) process.stdout.write(`${JSON.stringify({
22495
+ action: "restore",
22496
+ apply: false,
22497
+ name: options.name,
22498
+ error: refused
22499
+ }, null, 2)}\n`);
22500
+ fail(refused);
22501
+ }
22299
22502
  const items = (plan?.items ?? []).filter((item) => item.selected !== false);
22503
+ const archiveItems = plan?.items ?? [];
22504
+ if (options.exclude !== void 0) assertKnown(options.exclude, archiveItems, "--exclude", "restore");
22505
+ if (scope.kind === "include") assertKnown(scope.ids, archiveItems, "--include", "restore");
22300
22506
  if (options.json && !options.confirm) {
22301
22507
  process.stdout.write(`${JSON.stringify({
22302
22508
  action: "restore",
22303
22509
  apply: false,
22304
22510
  name: options.name,
22305
22511
  items,
22306
- warnings: plan?.warnings ?? []
22512
+ skipped: restoreNotes(plan)
22307
22513
  }, null, 2)}\n`);
22308
22514
  return;
22309
22515
  }
22310
22516
  if (!options.json) {
22311
- process.stdout.write(`${bold("Plan")} for ${options.name} — nothing has been written yet\n`);
22517
+ process.stdout.write(options.confirm ? `${bold("Plan")} for ${options.name} — applying it now\n` : `${bold("Plan")} for ${options.name} — nothing has been written yet\n`);
22312
22518
  printPlanTree(items.map((item) => ({
22313
22519
  id: item.id,
22314
22520
  note: item.note ?? null
22315
22521
  })));
22316
- for (const warning of plan?.warnings ?? []) process.stdout.write(` ${dim("!")} ${warning}\n`);
22522
+ if (!options.confirm) for (const note of restoreNotes(plan)) process.stdout.write(` ${dim("!")} ${note}\n`);
22317
22523
  if (items.length === 0) {
22318
22524
  process.stdout.write(" (nothing to restore — check --include, or what this host declares)\n");
22319
22525
  return;
@@ -22331,43 +22537,72 @@ async function runBackupRestore(options) {
22331
22537
  exclude: options.exclude
22332
22538
  });
22333
22539
  return {
22334
- items: (result.items ?? []).filter((item) => item.selected !== false),
22335
- hooks: (result.hooks ?? []).filter((hook) => hook.action === "load")
22540
+ ...result,
22541
+ items: (result.items ?? []).filter((item) => item.selected !== false)
22336
22542
  };
22337
22543
  }
22338
22544
  const runtime = await livePanel();
22339
22545
  if (runtime === null) fail("the control panel stopped answering — nothing further was written");
22340
- const base = new URLSearchParams({ name: options.name });
22341
- if (options.password !== void 0 && options.password.length > 0) base.set("password", options.password);
22342
- if (scope.kind === "include") base.set("include", scope.ids.join(","));
22343
- if (options.exclude !== void 0) base.set("exclude", options.exclude.join(","));
22546
+ const base = restoreQuery(options, scope);
22344
22547
  const answer = await runtime.request(runtime, `/_hh/backups/restore${withParam(suffixOf(base), "confirm", "true")}`, 6e5);
22345
22548
  if (answer === null) fail(`the control panel is not answering at ${runtime.probeUrl}`);
22346
22549
  if (answer.status !== 200) refusal(answer);
22347
22550
  const result = answer.body;
22348
22551
  return {
22552
+ ...result,
22349
22553
  items: (result?.items ?? plan?.items ?? []).filter((item) => item.selected !== false),
22350
- hooks: (result?.hooks ?? plan?.hooks ?? []).filter((hook) => hook.action === "load")
22554
+ ...result?.hooks === void 0 && plan?.hooks !== void 0 ? { hooks: plan.hooks } : {}
22351
22555
  };
22352
22556
  })();
22353
- const applied = outcome.items;
22557
+ const applyRefused = planRefusal(outcome);
22558
+ if (applyRefused !== null) {
22559
+ if (options.json) process.stdout.write(`${JSON.stringify({
22560
+ action: "restore",
22561
+ apply: true,
22562
+ name: options.name,
22563
+ error: applyRefused
22564
+ }, null, 2)}\n`);
22565
+ fail(applyRefused);
22566
+ }
22567
+ const applied = (outcome.items ?? []).filter((item) => item.selected !== false);
22568
+ const hooks = (outcome.hooks ?? []).filter((hook) => hook.action === "load");
22569
+ const notes = restoreNotes(plan);
22354
22570
  if (options.json) {
22355
22571
  process.stdout.write(`${JSON.stringify({
22356
22572
  action: "restore",
22357
22573
  apply: true,
22358
22574
  name: options.name,
22359
22575
  items: applied,
22360
- hooks: outcome.hooks,
22361
- warnings: plan?.warnings ?? []
22576
+ hooks,
22577
+ skipped: notes,
22578
+ ...outcome.restartRequired === true ? { restartRequired: true } : {},
22579
+ ...(outcome.createdWorkspaces ?? []).length === 0 ? {} : { createdWorkspaces: outcome.createdWorkspaces },
22580
+ ...(outcome.replacedUnderRunning ?? []).length === 0 ? {} : { replacedUnderRunning: outcome.replacedUnderRunning }
22362
22581
  }, null, 2)}\n`);
22363
22582
  return;
22364
22583
  }
22365
- process.stdout.write(`${green("restored")} ${applied.length} ${applied.length === 1 ? "item" : "items"} from ${options.name}\n`);
22366
- for (const hook of outcome.hooks) process.stdout.write(` ${dim(`load ${hook.serverId}: ${hook.output ?? "staged"}`)}\n`);
22367
- for (const warning of plan?.warnings ?? []) process.stdout.write(` ${dim("!")} ${warning}\n`);
22584
+ if (applied.length === 0) process.stdout.write(`${green("restored")} nothing — the archive carried no item this host can take\n`);
22585
+ else process.stdout.write(`${green("restored")} ${applied.length} ${applied.length === 1 ? "item" : "items"} from ${options.name}\n`);
22586
+ for (const hook of hooks) process.stdout.write(` ${dim(`load ${hook.serverId}: ${hook.output ?? "staged"}`)}\n`);
22587
+ for (const note of notes) process.stdout.write(` ${dim("!")} ${note}\n`);
22588
+ if (outcome.restartRequired === true) process.stdout.write(` ${dim(`! the panel's listener changed — restart it so it binds where the archive says (\`${invocation()} restart\`)`)}\n`);
22589
+ if ((outcome.createdWorkspaces ?? []).length > 0) process.stdout.write(` ${dim(`! created ${outcome.createdWorkspaces.join(", ")}, which this host did not have`)}\n`);
22368
22590
  if (service !== null) process.stdout.write(dim(`the panel is not running, so nothing was reloaded — the next \`${invocation()} up\` reads what was restored\n`));
22369
22591
  }
22370
22592
  }
22593
+ /**
22594
+ * The restore query both the plan and the apply send.
22595
+ *
22596
+ * One builder, because the two requests must agree: a password or a selection on the plan and not on
22597
+ * the apply made the apply answer about different items than the person approved.
22598
+ */
22599
+ function restoreQuery(options, scope) {
22600
+ const base = new URLSearchParams({ name: options.name });
22601
+ if (options.password !== void 0 && options.password.length > 0) base.set("password", options.password);
22602
+ if (scope.kind === "include") base.set("include", scope.ids.join(","));
22603
+ if (options.exclude !== void 0) base.set("exclude", options.exclude.join(","));
22604
+ return base;
22605
+ }
22371
22606
  var backupCommand;
22372
22607
  var init_backup = __esmMin((() => {
22373
22608
  init_backup_offline();
@@ -22548,7 +22783,7 @@ async function runNanny(spec, statePath) {
22548
22783
  };
22549
22784
  child.once("exit", (code, signal) => finish(code, signal, Date.now() - startedAt));
22550
22785
  child.once("error", (error) => {
22551
- finish(null, null, 0, `persistent: could not start the entry: ${error.message}`);
22786
+ finish(null, null, 0, `persistent: could not start the entry: ${describeSpawnError(error, spec.command, spec.cwd)}`);
22552
22787
  });
22553
22788
  });
22554
22789
  process.exit(exitCode);