@slayzone/cli 0.38.2 → 0.40.0

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.
Files changed (2) hide show
  1. package/dist/slay.js +308 -92
  2. package/package.json +1 -1
package/dist/slay.js CHANGED
@@ -16766,6 +16766,9 @@ var SLZ_FILE_PREFIX = `slz-file://${SLZ_FILE_HOST}`;
16766
16766
  // ../../shared/platform/src/ipc-dedup.ts
16767
16767
  var UNCHANGED = Object.freeze({ __ipc_unchanged__: true });
16768
16768
 
16769
+ // ../../shared/platform/src/isolation.ts
16770
+ var FAULT_BACKOFF_MAX_MS = 60 * 6e4;
16771
+
16769
16772
  // src/cli-state.ts
16770
16773
  function getCliStateDir() {
16771
16774
  const home = process.env.HOME ?? process.env.USERPROFILE ?? import_os2.default.homedir();
@@ -17527,7 +17530,12 @@ ${t.description}`);
17527
17530
  // src/commands/tasks/done.ts
17528
17531
  async function doneAction(idPrefix, opts) {
17529
17532
  idPrefix = await resolveId(idPrefix);
17530
- const { data: task } = await apiPost(`/api/tasks/${encodeURIComponent(idPrefix)}/done`, opts.close ? { close: true } : {});
17533
+ const { data: task } = await apiPost(`/api/tasks/${encodeURIComponent(idPrefix)}/done`, {
17534
+ ...opts.close ? { close: true } : {},
17535
+ // Completion stops every agent of the task; the hub refuses (409) while one
17536
+ // is mid-reply — this command's own agent included — unless --force.
17537
+ ...opts.force ? { force: true } : {}
17538
+ });
17531
17539
  console.log(`Done: ${task.id.slice(0, 8)} ${task.title}`);
17532
17540
  if (opts.close && !task.closed) {
17533
17541
  console.error("Warning: cannot close tab \u2014 no app window attached to this hub");
@@ -17536,18 +17544,25 @@ async function doneAction(idPrefix, opts) {
17536
17544
 
17537
17545
  // src/commands/tasks/reset-conversation.ts
17538
17546
  async function resetConversationAction(idPrefix, opts) {
17547
+ if (opts.tab !== void 0 && opts.allTabs) {
17548
+ console.error("Pass either --tab or --all-tabs, not both.");
17549
+ process.exit(1);
17550
+ }
17539
17551
  idPrefix = await resolveId(idPrefix);
17540
- const { data } = await apiPost(
17541
- `/api/tasks/${encodeURIComponent(idPrefix)}/reset-conversation`,
17542
- opts.mode ? { mode: opts.mode } : {}
17543
- );
17552
+ const { data } = await apiPost(`/api/tasks/${encodeURIComponent(idPrefix)}/reset-conversation`, {
17553
+ ...opts.mode ? { mode: opts.mode } : {},
17554
+ ...opts.tab !== void 0 ? { tab: opts.tab } : {},
17555
+ ...opts.allTabs ? { allTabs: true } : {}
17556
+ });
17544
17557
  const shortId = data.id.slice(0, 8);
17558
+ const tab = data.tab === "all" ? "all tabs" : data.tab === data.id ? "main tab" : `tab ${data.tab.slice(0, 8)}`;
17545
17559
  if (data.reset.length === 0) {
17546
- console.log(`No conversation rows for ${shortId} \u2014 nothing to reset.`);
17560
+ console.log(`No sessions for ${shortId} (${tab}) \u2014 nothing to reset.`);
17547
17561
  return;
17548
17562
  }
17549
17563
  for (const mode of data.reset) {
17550
- console.log(`Reset: ${shortId} mode=${mode} (next spawn starts fresh)`);
17564
+ const which = mode.startsWith("*") ? "every agent (applied when its computer connects)" : `mode=${mode}`;
17565
+ console.log(`Reset: ${shortId} ${tab} ${which} (next spawn starts fresh)`);
17551
17566
  }
17552
17567
  }
17553
17568
 
@@ -17635,6 +17650,7 @@ async function updateAction(idPrefix, opts) {
17635
17650
  if (opts.description !== void 0) body.description = opts.description || null;
17636
17651
  if (opts.appendDescription !== void 0) body.appendDescription = opts.appendDescription;
17637
17652
  if (opts.status !== void 0) body.status = opts.status;
17653
+ if (opts.force) body.force = true;
17638
17654
  if (opts.priority) body.priority = parseInt(opts.priority, 10);
17639
17655
  if (typeof opts.due === "string") body.dueDate = opts.due;
17640
17656
  else if (opts.due === false) body.dueDate = null;
@@ -17713,10 +17729,22 @@ async function archiveAction(idPrefix) {
17713
17729
  // src/commands/tasks/delete.ts
17714
17730
  async function deleteAction(idPrefix) {
17715
17731
  const { data, task } = await apiDelete(`/api/tasks/${encodeURIComponent(idPrefix)}`);
17716
- if (typeof data === "object" && data.blocked) {
17732
+ if (typeof data === "object" && "blocked" in data) {
17717
17733
  console.error(`Cannot delete: linked to external provider. Unlink first.`);
17718
17734
  process.exit(1);
17719
17735
  }
17736
+ if (typeof data === "object" && "incomplete" in data) {
17737
+ console.error(`Deletion is incomplete. Cleanup operation: ${data.erasure.id}`);
17738
+ for (const computer of data.erasure.computers.filter((c) => !c.deleted))
17739
+ console.error(`Data on ${computer.name} has not been deleted yet.`);
17740
+ process.exitCode = 2;
17741
+ return;
17742
+ }
17743
+ if (data !== true) {
17744
+ console.error("Task was not deleted.");
17745
+ process.exitCode = 1;
17746
+ return;
17747
+ }
17720
17748
  console.log(`Deleted: ${task.id.slice(0, 8)} ${task.title}`);
17721
17749
  }
17722
17750
 
@@ -22858,6 +22886,43 @@ Use \`slay tasks artifacts read ${artifactId}\` to get the content, or \`downloa
22858
22886
  console.log(`Moved: ${data.id.slice(0, 8)} -> ${targetName}`);
22859
22887
  }
22860
22888
  });
22889
+ cmd.command("move-to-task <destTaskId> [entryIds...]").addHelpText(
22890
+ "after",
22891
+ `
22892
+ Entry IDs are artifact or folder IDs (prefixes ok); a folder moves with everything in it.
22893
+ Examples:
22894
+ slay tasks artifacts move-to-task <dest> --all --from <src>
22895
+ slay tasks artifacts move-to-task <dest> <artifactId> <folderId> --into <destFolderId>`
22896
+ ).description(
22897
+ "Move artifacts and folders (with their contents) to another task, keeping ids, versions and artifact: links"
22898
+ ).option("--all", "Move every top-level artifact and folder of the source task").option(
22899
+ "--from <taskId>",
22900
+ "Source task (default: the entries' task, or $SLAYZONE_TASK_ID with --all)"
22901
+ ).option("--into <folderId>", "Destination folder in the target task (default: top level)").option("--json", "Output as JSON").action(async (destTaskId, entryIds, opts) => {
22902
+ const sourceTaskId = opts.from ?? (opts.all ? process.env.SLAYZONE_TASK_ID : void 0);
22903
+ if (opts.all && !sourceTaskId) {
22904
+ console.error("--all needs --from <taskId> (or $SLAYZONE_TASK_ID)");
22905
+ process.exit(1);
22906
+ }
22907
+ if (!opts.all && entryIds.length === 0) {
22908
+ console.error("Name artifact/folder IDs to move, or pass --all");
22909
+ process.exit(1);
22910
+ }
22911
+ const { data } = await apiPost("/api/artifacts/move", {
22912
+ destTaskId,
22913
+ ...sourceTaskId ? { sourceTaskId } : {},
22914
+ entryIds,
22915
+ destFolderId: opts.into ?? null,
22916
+ all: opts.all === true
22917
+ });
22918
+ if (opts.json) {
22919
+ console.log(JSON.stringify(data));
22920
+ } else {
22921
+ console.log(
22922
+ `Moved ${data.artifacts.length} artifact(s), ${data.folders.length} folder(s) -> ${data.destTaskId.slice(0, 8)} ${data.destTaskTitle}`
22923
+ );
22924
+ }
22925
+ });
22861
22926
  cmd.command("download [artifactId]").description("Download an artifact in a given format").option("--type <type>", "Export type: raw, pdf, png, html, zip", "raw").option("--output <path>", "Output file path (default: ./<filename>)").option("--task <id>", "Task ID for zip (or $SLAYZONE_TASK_ID)").option("--json", "Output as JSON").addHelpText(
22862
22927
  "after",
22863
22928
  `
@@ -23117,13 +23182,16 @@ function tasksCommand() {
23117
23182
  "Task description (reference task specific artifacts via `[title](artifact:<artifact-id>)`)"
23118
23183
  ).option("--status <status>", "Initial status key").option("--priority <n>", "Priority 1-5 (1=highest)").option("--due <date>", "Due date (YYYY-MM-DD or ISO 8601)").option("--template <name|id>", "Task template for defaults").option("--external-id <id>", "External ID for deduplication (skips if already exists)").option("--external-provider <provider>", "External provider namespace", "cli").action(createAction);
23119
23184
  cmd.command("view [id]").description("Show task details (id prefix supported; defaults to $SLAYZONE_TASK_ID)").action(viewAction);
23120
- cmd.command("done [id]").description("Mark a task as done (id prefix supported; defaults to $SLAYZONE_TASK_ID)").option("--close", "Also close the task tab in the app").action(doneAction);
23185
+ cmd.command("done [id]").description("Mark a task as done (id prefix supported; defaults to $SLAYZONE_TASK_ID)").option("--close", "Also close the task tab in the app").option(
23186
+ "--force",
23187
+ "Complete even while an agent of the task is mid-reply (completion stops every agent)"
23188
+ ).action(doneAction);
23121
23189
  cmd.command("reset-conversation [id]").description(
23122
- "Clear the stored conversation IDs for a task \u2014 the next agent spawn starts fresh. Appends a `manual-reset` row to task_conversations (append-only; never deletes)."
23190
+ "Reset a task's agent session \u2014 the next agent spawn in that tab starts fresh. Sessions are per terminal tab; default = the main tab. Append-only (never deletes)."
23123
23191
  ).option(
23124
23192
  "--mode <mode>",
23125
- "Limit to one agent (e.g. claude-code, codex). Default: every agent with a row for this task."
23126
- ).action(resetConversationAction);
23193
+ "Limit to one agent (e.g. claude-code, codex). Default: every agent with a session in scope."
23194
+ ).option("--tab <tab>", "One terminal tab of the task: id, unique id prefix, or label").option("--all-tabs", "Every terminal tab of the task").action(resetConversationAction);
23127
23195
  cmd.command("update [id]").description("Update a task (id prefix supported; defaults to $SLAYZONE_TASK_ID)").option("--title <title>", "New title").option(
23128
23196
  "--description <text>",
23129
23197
  "New description (reference task specific artifacts via `[title](artifact:<artifact-id>)`)"
@@ -23133,6 +23201,9 @@ function tasksCommand() {
23133
23201
  ).option(
23134
23202
  "--worktree-path <path>",
23135
23203
  "Link a git worktree to this task (auto-derives parent branch + repo from project layout)"
23204
+ ).option(
23205
+ "--force",
23206
+ "With a done/canceled --status: complete even while an agent of the task is mid-reply (completion stops every agent)"
23136
23207
  ).action(updateAction);
23137
23208
  cmd.command("progress <idOrValue> [value]").description(
23138
23209
  "Set task progress 0-100. Use `<id> <value>` or `<value>` (id defaults to $SLAYZONE_TASK_ID)."
@@ -45436,6 +45507,8 @@ If useful, you have a toolbox for acting on SlayZone itself. You can:
45436
45507
 
45437
45508
  The toolbox is the \`slay\` CLI. When you omit the task-id, most \`slay\` commands auto-resolve to your current task via \`$SLAYZONE_TASK_ID\` (always set in a task terminal). Trust the resolution: just run the command, don't check or echo the env vars, and pass an explicit task-id only when you deliberately target a different task. **Load the \`slay\` skill before running any \`slay\` command** \u2014 it holds the full reference of commands, flags, and domain-specific guides. Never guess subcommands or flags.
45438
45509
 
45510
+ Never read or write SlayZone's own data (\`$SLAYZONE_ROOT\`, \`~/.slayzone\`, its SQLite databases) directly: the running app and its computers hold copies that a direct edit silently breaks. If \`slay\` cannot do something, stop and ask.
45511
+
45439
45512
  Prefer native file-editing tools for ordinary source changes. Use scripts when bulk transformations materially benefit from them. Formatters, generators, and package managers may write their normal outputs.
45440
45513
  `;
45441
45514
  function writeInstructionsToDisk(projectPath, providers) {
@@ -46806,11 +46879,109 @@ function panelsCommand() {
46806
46879
 
46807
46880
  // src/commands/hub.ts
46808
46881
  var import_node_child_process5 = require("node:child_process");
46809
- var import_node_fs11 = require("node:fs");
46882
+ var import_node_fs12 = require("node:fs");
46810
46883
  var import_node_path11 = require("node:path");
46811
46884
 
46812
- // ../../shared/platform/src/slayzone-config.ts
46885
+ // src/commands/hub-erasure.ts
46813
46886
  var import_node_fs6 = require("node:fs");
46887
+ function registerHubErasureCommands(users, accounts, erasure) {
46888
+ async function userId(email3) {
46889
+ const list = await accounts("GET");
46890
+ const user = list.find((u) => u.email.toLowerCase() === email3.trim().toLowerCase());
46891
+ if (!user) throw new Error("User not found on the selected hub.");
46892
+ return user.id;
46893
+ }
46894
+ function show(report, json2) {
46895
+ if (json2) console.log(JSON.stringify(report, null, 2));
46896
+ else {
46897
+ console.log(
46898
+ `${report.state === "complete" ? "SlayZone content erased." : "Some data has not been deleted yet."} Operation: ${report.id}`
46899
+ );
46900
+ for (const computer of report.computers.filter((c) => !c.deleted))
46901
+ console.log(`Data on ${computer.name} has not been deleted yet.`);
46902
+ if (report.failures.length) console.log(`Cleanup failures: ${report.failures.join(", ")}`);
46903
+ }
46904
+ if (report.state !== "complete") process.exitCode = 2;
46905
+ }
46906
+ users.command("erase-content <email>").description("Preview permanent erasure of a disabled user\u2019s content; --confirm performs it").option("--confirm <email>", "Confirm the selected email and permanently erase its content").option("--json", "Output JSON").action(async (email3, opts) => {
46907
+ const id = await userId(email3);
46908
+ if (opts.confirm === void 0) {
46909
+ const preview = await erasure("GET", void 0, {
46910
+ view: "preview",
46911
+ userId: id
46912
+ });
46913
+ console.log(JSON.stringify(preview, null, 2));
46914
+ if (!opts.json)
46915
+ console.log("Preview only. To erase permanently, repeat with --confirm <selected email>.");
46916
+ return;
46917
+ }
46918
+ if (opts.confirm.trim().toLowerCase() !== email3.trim().toLowerCase())
46919
+ throw new Error("--confirm must match the selected email.");
46920
+ show(
46921
+ await erasure("POST", {
46922
+ action: "erase-content",
46923
+ userId: id,
46924
+ confirmation: opts.confirm
46925
+ }),
46926
+ opts.json
46927
+ );
46928
+ });
46929
+ users.command("erasure-status <email>").description("Show erasure progress and remaining computer copies").option("--json", "Output JSON").action(async (email3, opts) => {
46930
+ const reports = await erasure("GET", void 0, {
46931
+ view: "reports",
46932
+ userId: await userId(email3)
46933
+ });
46934
+ if (opts.json) {
46935
+ console.log(JSON.stringify(reports, null, 2));
46936
+ if (reports.some((report) => report.state === "incomplete")) process.exitCode = 2;
46937
+ return;
46938
+ }
46939
+ if (!reports.length) console.log("No erasure operations recorded.");
46940
+ for (const report of reports) show(report, opts.json);
46941
+ });
46942
+ users.command("retry-erasure <job-id>").description("Resume an already-confirmed erasure").option("--json", "Output JSON").action(
46943
+ async (jobId, opts) => show(await erasure("POST", { action: "retry-erasure", jobId }), opts.json)
46944
+ );
46945
+ users.command("erasure-receipt <job-id>").description("Save non-content erasure evidence outside the hub backup").requiredOption("--output <path>", "Create a new receipt file").action(async (jobId, opts) => {
46946
+ const receipt = await erasure("POST", { action: "receipt", jobId });
46947
+ save(opts.output, receipt);
46948
+ console.log(`Saved erasure receipt: ${opts.output}`);
46949
+ });
46950
+ users.command("computer-erasure-request <job-id> <computer-id>").description("Create an offline cleanup request containing identifiers only").requiredOption(
46951
+ "--computer-hub-url <url>",
46952
+ "The exact URL this computer used, ending in /computers"
46953
+ ).requiredOption("--output <path>", "Create a new request file").action(
46954
+ async (jobId, computerId, opts) => {
46955
+ const data = await erasure("POST", {
46956
+ action: "computer-erasure-request",
46957
+ jobId,
46958
+ computerId,
46959
+ hubUrl: opts.computerHubUrl
46960
+ });
46961
+ save(opts.output, data);
46962
+ console.log(`Saved offline cleanup request: ${opts.output}`);
46963
+ }
46964
+ );
46965
+ users.command("confirm-computer-erasure <receipt-file>").description("Record operator verification from an offline computer cleanup receipt").option("--json", "Output JSON").action(async (file2, opts) => {
46966
+ const receipt = JSON.parse((0, import_node_fs6.readFileSync)(file2, "utf8"));
46967
+ show(
46968
+ await erasure("POST", { action: "confirm-computer-erasure", receipt }),
46969
+ opts.json
46970
+ );
46971
+ });
46972
+ }
46973
+ function save(path12, value) {
46974
+ (0, import_node_fs6.writeFileSync)(path12, JSON.stringify(value, null, 2) + "\n", { flag: "wx", mode: 384 });
46975
+ const fd = (0, import_node_fs6.openSync)(path12, "r");
46976
+ try {
46977
+ (0, import_node_fs6.fsyncSync)(fd);
46978
+ } finally {
46979
+ (0, import_node_fs6.closeSync)(fd);
46980
+ }
46981
+ }
46982
+
46983
+ // ../../shared/platform/src/slayzone-config.ts
46984
+ var import_node_fs7 = require("node:fs");
46814
46985
  var import_node_path7 = require("node:path");
46815
46986
  var HUB_CONFIG_SWITCH_KEYS = [
46816
46987
  "requireLogin",
@@ -46871,7 +47042,7 @@ function coerceComputerConfig(raw) {
46871
47042
  function readJsonObject2(path12) {
46872
47043
  let raw;
46873
47044
  try {
46874
- raw = (0, import_node_fs6.readFileSync)(path12, "utf8");
47045
+ raw = (0, import_node_fs7.readFileSync)(path12, "utf8");
46875
47046
  } catch (err) {
46876
47047
  if (err.code === "ENOENT") return null;
46877
47048
  process.stderr.write(
@@ -46899,14 +47070,14 @@ function readJsonObject2(path12) {
46899
47070
  }
46900
47071
  function writeJsonAtomic(path12, data) {
46901
47072
  const dir = (0, import_node_path7.dirname)(path12);
46902
- (0, import_node_fs6.mkdirSync)(dir, { recursive: true, mode: 448 });
47073
+ (0, import_node_fs7.mkdirSync)(dir, { recursive: true, mode: 448 });
46903
47074
  const tmpPath = `${path12}.tmp-${process.pid}-${Date.now()}`;
46904
- (0, import_node_fs6.writeFileSync)(tmpPath, `${JSON.stringify(data, null, 2)}
47075
+ (0, import_node_fs7.writeFileSync)(tmpPath, `${JSON.stringify(data, null, 2)}
46905
47076
  `, { mode: 384 });
46906
47077
  try {
46907
- (0, import_node_fs6.renameSync)(tmpPath, path12);
47078
+ (0, import_node_fs7.renameSync)(tmpPath, path12);
46908
47079
  } catch (err) {
46909
- (0, import_node_fs6.rmSync)(tmpPath, { force: true });
47080
+ (0, import_node_fs7.rmSync)(tmpPath, { force: true });
46910
47081
  throw err;
46911
47082
  }
46912
47083
  }
@@ -46943,7 +47114,7 @@ function updateComputerConfigFile(patch, path12 = getComputerConfigFilePath()) {
46943
47114
 
46944
47115
  // ../../shared/platform/src/service-unit.ts
46945
47116
  var import_node_child_process2 = require("node:child_process");
46946
- var import_node_fs7 = require("node:fs");
47117
+ var import_node_fs8 = require("node:fs");
46947
47118
  var import_node_os2 = require("node:os");
46948
47119
  var import_node_path8 = require("node:path");
46949
47120
  var KINDS = {
@@ -46999,7 +47170,7 @@ function derivedRuntimeDir() {
46999
47170
  const uid = process.getuid?.();
47000
47171
  if (uid === void 0) return null;
47001
47172
  const dir = `/run/user/${uid}`;
47002
- return (0, import_node_fs7.existsSync)(dir) ? dir : null;
47173
+ return (0, import_node_fs8.existsSync)(dir) ? dir : null;
47003
47174
  }
47004
47175
  function userServiceEnv() {
47005
47176
  const dir = derivedRuntimeDir();
@@ -47157,34 +47328,34 @@ WantedBy=default.target
47157
47328
  }
47158
47329
  function writeUnit(spec, backend, unitDir = defaultUnitDir(backend)) {
47159
47330
  const path12 = unitPath(spec.kind, spec.name, backend, unitDir);
47160
- (0, import_node_fs7.mkdirSync)(unitDir, { recursive: true });
47331
+ (0, import_node_fs8.mkdirSync)(unitDir, { recursive: true });
47161
47332
  const content = backend === "launchd" ? renderLaunchdPlist(spec) : renderSystemdUnit(spec);
47162
47333
  if (!unitHoldsSecret(spec)) {
47163
- (0, import_node_fs7.writeFileSync)(path12, content, { mode: 420 });
47334
+ (0, import_node_fs8.writeFileSync)(path12, content, { mode: 420 });
47164
47335
  return path12;
47165
47336
  }
47166
47337
  const tmp = `${path12}.${process.pid}.tmp`;
47167
- (0, import_node_fs7.rmSync)(tmp, { force: true });
47338
+ (0, import_node_fs8.rmSync)(tmp, { force: true });
47168
47339
  try {
47169
- (0, import_node_fs7.writeFileSync)(tmp, content, { mode: 384, flag: "wx" });
47170
- (0, import_node_fs7.chmodSync)(tmp, 384);
47171
- (0, import_node_fs7.renameSync)(tmp, path12);
47340
+ (0, import_node_fs8.writeFileSync)(tmp, content, { mode: 384, flag: "wx" });
47341
+ (0, import_node_fs8.chmodSync)(tmp, 384);
47342
+ (0, import_node_fs8.renameSync)(tmp, path12);
47172
47343
  } catch (err) {
47173
- (0, import_node_fs7.rmSync)(tmp, { force: true });
47344
+ (0, import_node_fs8.rmSync)(tmp, { force: true });
47174
47345
  throw err;
47175
47346
  }
47176
47347
  return path12;
47177
47348
  }
47178
47349
  function removeUnit(kind, name, backend, unitDir = defaultUnitDir(backend)) {
47179
47350
  const path12 = unitPath(kind, name, backend, unitDir);
47180
- if (!(0, import_node_fs7.existsSync)(path12)) return false;
47181
- (0, import_node_fs7.rmSync)(path12, { force: true });
47351
+ if (!(0, import_node_fs8.existsSync)(path12)) return false;
47352
+ (0, import_node_fs8.rmSync)(path12, { force: true });
47182
47353
  return true;
47183
47354
  }
47184
47355
  function listRegisteredUnits(kind, backend, unitDir = defaultUnitDir(backend)) {
47185
47356
  let files;
47186
47357
  try {
47187
- files = (0, import_node_fs7.readdirSync)(unitDir);
47358
+ files = (0, import_node_fs8.readdirSync)(unitDir);
47188
47359
  } catch {
47189
47360
  return [];
47190
47361
  }
@@ -47198,7 +47369,7 @@ function listRegisteredUnits(kind, backend, unitDir = defaultUnitDir(backend)) {
47198
47369
  function readUnitRoot(kind, name, backend, unitDir = defaultUnitDir(backend)) {
47199
47370
  let text;
47200
47371
  try {
47201
- text = (0, import_node_fs7.readFileSync)(unitPath(kind, name, backend, unitDir), "utf8");
47372
+ text = (0, import_node_fs8.readFileSync)(unitPath(kind, name, backend, unitDir), "utf8");
47202
47373
  } catch {
47203
47374
  return null;
47204
47375
  }
@@ -47221,7 +47392,7 @@ function launchdLabel(kind, name) {
47221
47392
  function readUnitEnv(kind, name, backend, unitDir = defaultUnitDir(backend)) {
47222
47393
  let text;
47223
47394
  try {
47224
- text = (0, import_node_fs7.readFileSync)(unitPath(kind, name, backend, unitDir), "utf8");
47395
+ text = (0, import_node_fs8.readFileSync)(unitPath(kind, name, backend, unitDir), "utf8");
47225
47396
  } catch {
47226
47397
  return {};
47227
47398
  }
@@ -47246,9 +47417,9 @@ function readUnitSecrets(kind, name, backend, unitDir = defaultUnitDir(backend))
47246
47417
  }
47247
47418
 
47248
47419
  // ../../shared/platform/src/computer-launcher.ts
47249
- var import_node_fs8 = require("node:fs");
47250
- var import_node_path9 = require("node:path");
47251
47420
  var import_node_fs9 = require("node:fs");
47421
+ var import_node_path9 = require("node:path");
47422
+ var import_node_fs10 = require("node:fs");
47252
47423
  var COMPUTER_LAUNCHER = String.raw`#!/usr/bin/env node
47253
47424
  const fs = require('node:fs'), path = require('node:path'), cp = require('node:child_process');
47254
47425
  const root = process.env.SLAYZONE_ROOT;
@@ -47290,9 +47461,9 @@ launch();
47290
47461
  `;
47291
47462
  function ensureComputerLauncher(root, release, forceUpgrade = false) {
47292
47463
  const dir = (0, import_node_path9.join)(root, "computer-runtime");
47293
- (0, import_node_fs8.mkdirSync)(dir, { recursive: true, mode: 448 });
47464
+ (0, import_node_fs9.mkdirSync)(dir, { recursive: true, mode: 448 });
47294
47465
  const launcher = (0, import_node_path9.join)(dir, "launch.cjs");
47295
- (0, import_node_fs8.writeFileSync)(launcher + ".tmp", COMPUTER_LAUNCHER, { mode: 448 });
47466
+ (0, import_node_fs9.writeFileSync)(launcher + ".tmp", COMPUTER_LAUNCHER, { mode: 448 });
47296
47467
  renameLauncher(launcher);
47297
47468
  if (forceUpgrade) {
47298
47469
  for (const name of ["supervisor.json", "host-release.json"]) {
@@ -47302,35 +47473,35 @@ function ensureComputerLauncher(root, release, forceUpgrade = false) {
47302
47473
  previous = JSON.parse(readPointer(path12)).current;
47303
47474
  } catch {
47304
47475
  }
47305
- (0, import_node_fs8.writeFileSync)(
47476
+ (0, import_node_fs9.writeFileSync)(
47306
47477
  path12 + ".tmp",
47307
47478
  JSON.stringify({ current: release, ...previous ? { previous } : {} }),
47308
47479
  { mode: 384 }
47309
47480
  );
47310
- (0, import_node_fs9.renameSync)(path12 + ".tmp", path12);
47481
+ (0, import_node_fs10.renameSync)(path12 + ".tmp", path12);
47311
47482
  }
47312
47483
  }
47313
47484
  const hostPointer = (0, import_node_path9.join)(dir, "host-release.json");
47314
- if (!(0, import_node_fs8.existsSync)(hostPointer))
47315
- (0, import_node_fs8.writeFileSync)(hostPointer, JSON.stringify({ current: release }), { mode: 384, flag: "wx" });
47485
+ if (!(0, import_node_fs9.existsSync)(hostPointer))
47486
+ (0, import_node_fs9.writeFileSync)(hostPointer, JSON.stringify({ current: release }), { mode: 384, flag: "wx" });
47316
47487
  const pointer = (0, import_node_path9.join)(dir, "supervisor.json");
47317
- if (!(0, import_node_fs8.existsSync)(pointer))
47318
- (0, import_node_fs8.writeFileSync)(pointer, JSON.stringify({ current: release }), { mode: 384, flag: "wx" });
47488
+ if (!(0, import_node_fs9.existsSync)(pointer))
47489
+ (0, import_node_fs9.writeFileSync)(pointer, JSON.stringify({ current: release }), { mode: 384, flag: "wx" });
47319
47490
  return launcher;
47320
47491
  }
47321
47492
  function readPointer(path12) {
47322
- return (0, import_node_fs9.readFileSync)(path12, "utf8");
47493
+ return (0, import_node_fs10.readFileSync)(path12, "utf8");
47323
47494
  }
47324
47495
  function renameLauncher(path12) {
47325
- (0, import_node_fs9.renameSync)(path12 + ".tmp", path12);
47496
+ (0, import_node_fs10.renameSync)(path12 + ".tmp", path12);
47326
47497
  }
47327
47498
 
47328
47499
  // src/service.ts
47329
47500
  var import_node_child_process3 = require("node:child_process");
47330
- var import_node_fs10 = require("node:fs");
47501
+ var import_node_fs11 = require("node:fs");
47331
47502
  var import_node_module = require("node:module");
47332
47503
  var import_node_path10 = require("node:path");
47333
- var CLI_VERSION = true ? "0.38.2" : "";
47504
+ var CLI_VERSION = true ? "0.40.0" : "";
47334
47505
  function fail(message) {
47335
47506
  console.error(message);
47336
47507
  process.exit(1);
@@ -47363,25 +47534,25 @@ function servicePackage(kind) {
47363
47534
  function readServicePkg(kind, pkgJsonPath) {
47364
47535
  let pkg;
47365
47536
  try {
47366
- pkg = JSON.parse((0, import_node_fs10.readFileSync)(pkgJsonPath, "utf8"));
47537
+ pkg = JSON.parse((0, import_node_fs11.readFileSync)(pkgJsonPath, "utf8"));
47367
47538
  } catch {
47368
47539
  return null;
47369
47540
  }
47370
47541
  const binRel = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.[PACKAGES[kind].bin];
47371
47542
  if (!binRel) return null;
47372
47543
  const binPath = (0, import_node_path10.join)((0, import_node_path10.dirname)(pkgJsonPath), binRel);
47373
- if (!(0, import_node_fs10.existsSync)(binPath)) return null;
47544
+ if (!(0, import_node_fs11.existsSync)(binPath)) return null;
47374
47545
  return { binPath, version: pkg.version ?? "unknown" };
47375
47546
  }
47376
47547
  function interpreterFor(binPath, version2) {
47377
47548
  let dir = (0, import_node_path10.dirname)(binPath);
47378
47549
  for (let i = 0; i < 6; i++) {
47379
47550
  const pathTxt = (0, import_node_path10.join)(dir, "node_modules", "electron", "path.txt");
47380
- if ((0, import_node_fs10.existsSync)(pathTxt)) {
47551
+ if ((0, import_node_fs11.existsSync)(pathTxt)) {
47381
47552
  try {
47382
- const rel = (0, import_node_fs10.readFileSync)(pathTxt, "utf8").trim();
47553
+ const rel = (0, import_node_fs11.readFileSync)(pathTxt, "utf8").trim();
47383
47554
  const electron = (0, import_node_path10.join)(dir, "node_modules", "electron", "dist", rel);
47384
- if ((0, import_node_fs10.existsSync)(electron)) {
47555
+ if ((0, import_node_fs11.existsSync)(electron)) {
47385
47556
  return {
47386
47557
  command: electron,
47387
47558
  args: [binPath],
@@ -47433,7 +47604,7 @@ function resolveServiceBin(kind, computerRoot, forceUpgrade = false) {
47433
47604
  const self2 = process.argv[1];
47434
47605
  if (!self2) return null;
47435
47606
  const sibling = (0, import_node_path10.join)((0, import_node_path10.dirname)(self2), "..", "..", devDir, "package.json");
47436
- return (0, import_node_fs10.existsSync)(sibling) ? sibling : null;
47607
+ return (0, import_node_fs11.existsSync)(sibling) ? sibling : null;
47437
47608
  }
47438
47609
  ];
47439
47610
  for (const find of candidates) {
@@ -47445,9 +47616,9 @@ function resolveServiceBin(kind, computerRoot, forceUpgrade = false) {
47445
47616
  const prefix = getServiceRuntimeDir(kind);
47446
47617
  const installed = (0, import_node_path10.join)(prefix, "node_modules", pkg, "package.json");
47447
47618
  const wanted = CLI_VERSION ? `${pkg}@${CLI_VERSION}` : `${pkg}@beta`;
47448
- if (!(0, import_node_fs10.existsSync)(installed) || CLI_VERSION && readServicePkg(kind, installed)?.version !== CLI_VERSION) {
47619
+ if (!(0, import_node_fs11.existsSync)(installed) || CLI_VERSION && readServicePkg(kind, installed)?.version !== CLI_VERSION) {
47449
47620
  console.log(`Installing ${wanted}\u2026`);
47450
- (0, import_node_fs10.mkdirSync)(prefix, { recursive: true });
47621
+ (0, import_node_fs11.mkdirSync)(prefix, { recursive: true });
47451
47622
  try {
47452
47623
  (0, import_node_child_process3.execFileSync)(
47453
47624
  "npm",
@@ -47472,7 +47643,7 @@ function resolveServiceBin(kind, computerRoot, forceUpgrade = false) {
47472
47643
  }
47473
47644
  function ensureLogDir(kind, root) {
47474
47645
  const dir = logDirFor(kind, root);
47475
- (0, import_node_fs10.mkdirSync)(dir, { recursive: true });
47646
+ (0, import_node_fs11.mkdirSync)(dir, { recursive: true });
47476
47647
  return dir;
47477
47648
  }
47478
47649
  function logDirFor(_kind, root) {
@@ -47486,7 +47657,7 @@ function serviceLogPaths(kind, root) {
47486
47657
  function failWithLog(kind, name, logPath, what) {
47487
47658
  let detail = "";
47488
47659
  try {
47489
- detail = (0, import_node_fs10.readFileSync)(logPath, "utf8").trim().split("\n").slice(-12).join("\n");
47660
+ detail = (0, import_node_fs11.readFileSync)(logPath, "utf8").trim().split("\n").slice(-12).join("\n");
47490
47661
  } catch {
47491
47662
  }
47492
47663
  const label = kind === "hub" ? "Hub" : "Computer";
@@ -47515,14 +47686,14 @@ function readServiceLogTail(kind, root, lines, systemdUnit) {
47515
47686
  const dir = logDirFor(kind, root);
47516
47687
  let files;
47517
47688
  try {
47518
- files = (0, import_node_fs10.readdirSync)(dir).filter((f) => f.endsWith(".log"));
47689
+ files = (0, import_node_fs11.readdirSync)(dir).filter((f) => f.endsWith(".log"));
47519
47690
  } catch {
47520
47691
  return "";
47521
47692
  }
47522
47693
  const chunks = [];
47523
47694
  for (const f of files) {
47524
47695
  try {
47525
- chunks.push((0, import_node_fs10.readFileSync)((0, import_node_path10.join)(dir, f), "utf8"));
47696
+ chunks.push((0, import_node_fs11.readFileSync)((0, import_node_path10.join)(dir, f), "utf8"));
47526
47697
  } catch {
47527
47698
  }
47528
47699
  }
@@ -47538,8 +47709,8 @@ function followServiceLog(args) {
47538
47709
  return;
47539
47710
  }
47540
47711
  const dir = logDirFor(kind, root);
47541
- if (!(0, import_node_fs10.existsSync)(dir)) fail(`No log directory at ${shortenPath(dir)}.`);
47542
- const candidates = (0, import_node_fs10.readdirSync)(dir).filter((f) => f.endsWith(".log")).map((f) => ({ f, path: (0, import_node_path10.join)(dir, f), mtime: (0, import_node_fs10.statSync)((0, import_node_path10.join)(dir, f)).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
47712
+ if (!(0, import_node_fs11.existsSync)(dir)) fail(`No log directory at ${shortenPath(dir)}.`);
47713
+ const candidates = (0, import_node_fs11.readdirSync)(dir).filter((f) => f.endsWith(".log")).map((f) => ({ f, path: (0, import_node_path10.join)(dir, f), mtime: (0, import_node_fs11.statSync)((0, import_node_path10.join)(dir, f)).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
47543
47714
  if (candidates.length === 0) fail(`No log files in ${shortenPath(dir)}.`);
47544
47715
  const target = candidates[0].path;
47545
47716
  const targs = follow ? ["-f", "-n", String(lines), target] : ["-n", String(lines), target];
@@ -48297,7 +48468,7 @@ function hubComputersRequest(method, path12, body) {
48297
48468
  );
48298
48469
  }
48299
48470
  function hubComputersCommand() {
48300
- const computers = new Command("computers").description("List, revoke and restore the computers enrolled on a hub (admin)").showHelpAfterError(true);
48471
+ const computers = new Command("computers").description("List, revoke, restore and replace the computers enrolled on a hub (admin)").showHelpAfterError(true);
48301
48472
  computers.command("ls").description("List the computers enrolled on a hub (not revoked)").option("--json", "Output as JSON").action(async (opts) => {
48302
48473
  const rows = await hubComputersRequest("GET", "/api/computers");
48303
48474
  if (opts.json) {
@@ -48317,6 +48488,15 @@ function hubComputersCommand() {
48317
48488
  `${r.id.padEnd(idW)} ${r.name.padEnd(nameW)} ${(r.connected ? "yes" : "no").padEnd(9)} ${seen}`
48318
48489
  );
48319
48490
  }
48491
+ const offers = await hubComputersRequest(
48492
+ "GET",
48493
+ "/api/hub/computers/takeovers"
48494
+ ).catch(() => []);
48495
+ if (offers.length > 0)
48496
+ console.log(
48497
+ `
48498
+ A computer holds the chats of an offline computer (enrolled again?): ${offers.length} takeover${offers.length === 1 ? "" : "s"} offered. See \`slay hub computers takeovers\`.`
48499
+ );
48320
48500
  });
48321
48501
  computers.command("revoke <id>").description("Revoke a computer: drop its connection and refuse its key (reversible)").action(async (id) => {
48322
48502
  await hubComputersRequest("PATCH", "/api/hub/computers", { id, revoked: true });
@@ -48326,6 +48506,39 @@ function hubComputersCommand() {
48326
48506
  await hubComputersRequest("PATCH", "/api/hub/computers", { id, revoked: false });
48327
48507
  console.log(`Restored computer ${id}.`);
48328
48508
  });
48509
+ computers.command("takeovers").description("List computers that hold the chats of an offline computer (re-enrolled?)").option("--json", "Output as JSON").action(async (opts) => {
48510
+ const offers = await hubComputersRequest(
48511
+ "GET",
48512
+ "/api/hub/computers/takeovers"
48513
+ );
48514
+ if (opts.json) {
48515
+ console.log(JSON.stringify(offers, null, 2));
48516
+ return;
48517
+ }
48518
+ if (offers.length === 0) {
48519
+ console.log("No computer holds the chats of an offline one.");
48520
+ return;
48521
+ }
48522
+ for (const o of offers) {
48523
+ const chats = `${o.conversations} chat${o.conversations === 1 ? "" : "s"}`;
48524
+ const tasks = `${o.tasks} task${o.tasks === 1 ? "" : "s"}`;
48525
+ console.log(
48526
+ `${o.successor.name} (${o.successor.id}) holds ${chats} in ${tasks} of ${o.former.name} (${o.former.id}), which is offline${o.former.revoked ? " and revoked" : ""}.`
48527
+ );
48528
+ console.log(
48529
+ ` If it is that computer enrolled again, replace it: slay hub computers replace ${o.former.id} --with ${o.successor.id}`
48530
+ );
48531
+ }
48532
+ });
48533
+ computers.command("replace <id>").description(
48534
+ "Replace an offline computer with the same machine enrolled again: its tasks, folders and chats move to the successor, and the old one is deleted"
48535
+ ).requiredOption("--with <successor-id>", "The computer that takes over (the re-enrolled one)").action(async (id, opts) => {
48536
+ await hubComputersRequest("POST", "/api/hub/computers/replace", {
48537
+ id,
48538
+ successorId: opts.with
48539
+ });
48540
+ console.log(`Replaced computer ${id} with ${opts.with}; ${id} is deleted.`);
48541
+ });
48329
48542
  return computers;
48330
48543
  }
48331
48544
 
@@ -48416,7 +48629,7 @@ async function launchHub(args) {
48416
48629
  const probePort = address !== void 0 ? parseHubAddress(address)?.port : port;
48417
48630
  const findIt = () => probePort === void 0 ? findAnyHub(name) : findHub(String(probePort));
48418
48631
  if (backend === "none") {
48419
- const out = (0, import_node_fs11.openSync)(logs.out, "a");
48632
+ const out = (0, import_node_fs12.openSync)(logs.out, "a");
48420
48633
  const child = (0, import_node_child_process5.spawn)(bin.command, bin.args, {
48421
48634
  cwd: root,
48422
48635
  detached: true,
@@ -48523,7 +48736,7 @@ then log out and back in, and retry. If this account is not meant to have one (a
48523
48736
  }
48524
48737
  }
48525
48738
  async function haltHub(hub, backend, opts) {
48526
- if (backend !== "none" && (0, import_node_fs11.existsSync)(unitPath("hub", hub.name, backend))) {
48739
+ if (backend !== "none" && (0, import_node_fs12.existsSync)(unitPath("hub", hub.name, backend))) {
48527
48740
  supervisorStop("hub", backend, hub.name);
48528
48741
  if (opts.unregister) removeUnit("hub", hub.name, backend);
48529
48742
  } else {
@@ -48546,19 +48759,22 @@ async function readPasswordFromStdin() {
48546
48759
  for await (const chunk of process.stdin) chunks.push(chunk);
48547
48760
  return Buffer.concat(chunks).toString("utf8").replace(/\r?\n$/, "");
48548
48761
  }
48549
- function hubUsersRequest(method, body) {
48550
- return resolveHubRequestTarget("hub users \u2026", discoverAllHubs).then(
48762
+ function hubUsersRouteRequest(path12) {
48763
+ return (method, body, query) => resolveHubRequestTarget("hub users \u2026", discoverAllHubs).then(
48551
48764
  (target) => hubRequest({
48552
48765
  target,
48553
- path: "/api/hub/users",
48766
+ path: path12 + (query ? "?" + new URLSearchParams(query).toString() : ""),
48554
48767
  method,
48555
48768
  ...body === void 0 ? {} : { body },
48556
48769
  unwrap: "data"
48557
48770
  })
48558
48771
  );
48559
48772
  }
48773
+ var hubUsersRequest = hubUsersRouteRequest("/api/hub/users");
48774
+ var hubContentErasureRequest = hubUsersRouteRequest("/api/hub/content-erasure");
48560
48775
  function hubUsersCommand() {
48561
48776
  const users = new Command("users").description("Manage the accounts that can sign in to a hub").showSuggestionAfterError(true).showHelpAfterError(true);
48777
+ registerHubErasureCommands(users, hubUsersRequest, hubContentErasureRequest);
48562
48778
  users.command("add <email>").description("Create an account and print its generated password once").option("--name <name>", "Display name (default: the email local part)").option("--admin", "Make the account an admin (the first account on a hub always is)").option("--json", "Output as JSON").action(async (email3, opts) => {
48563
48779
  const created = await hubUsersRequest("POST", {
48564
48780
  email: email3,
@@ -48770,7 +48986,7 @@ It is written into the hub's service unit (owner-only, 0600) so the hub keeps it
48770
48986
  );
48771
48987
  }
48772
48988
  const backend = resolveBackend();
48773
- if (backend !== "none" && (0, import_node_fs11.existsSync)(unitPath("hub", name, backend))) {
48989
+ if (backend !== "none" && (0, import_node_fs12.existsSync)(unitPath("hub", name, backend))) {
48774
48990
  const existingRoot = readUnitRoot("hub", name, backend);
48775
48991
  fail(
48776
48992
  `A hub named "${name}" already exists${existingRoot ? ` (root ${shortenPath(existingRoot)})` : ""}.
@@ -48855,7 +49071,7 @@ machines dial, recreate it with \`--public-address <host:port>\`.`
48855
49071
  `This platform has no user service manager, so hubs are not registered and \`start\` has nothing to act on. Use \`slay hub create ${name}\`.`
48856
49072
  );
48857
49073
  }
48858
- if (!(0, import_node_fs11.existsSync)(unitPath("hub", name, backend))) {
49074
+ if (!(0, import_node_fs12.existsSync)(unitPath("hub", name, backend))) {
48859
49075
  fail(
48860
49076
  `No hub named "${name}". Create it with \`slay hub create ${name}\`, or list what exists with \`slay hub registered\`.`
48861
49077
  );
@@ -48878,7 +49094,7 @@ machines dial, recreate it with \`--public-address <host:port>\`.`
48878
49094
  const hub = await requireHub(nameOrPort);
48879
49095
  refuseSupervised(hub, "stop");
48880
49096
  const backend = resolveBackend();
48881
- const registered = backend !== "none" && (0, import_node_fs11.existsSync)(unitPath("hub", hub.name, backend));
49097
+ const registered = backend !== "none" && (0, import_node_fs12.existsSync)(unitPath("hub", hub.name, backend));
48882
49098
  await haltHub(hub, backend, { unregister: false });
48883
49099
  console.log(
48884
49100
  registered ? `Stopped "${hub.name}". Start it again with \`slay hub start ${hub.name}\`.` : `Stopped "${hub.name}" (pid ${hub.pid}). It was not registered by slay.`
@@ -48888,7 +49104,7 @@ machines dial, recreate it with \`--public-address <host:port>\`.`
48888
49104
  const backend = resolveBackend();
48889
49105
  const hub = await findAnyHub(nameOrPort);
48890
49106
  if (!hub) {
48891
- if (backend !== "none" && (0, import_node_fs11.existsSync)(unitPath("hub", nameOrPort, backend))) {
49107
+ if (backend !== "none" && (0, import_node_fs12.existsSync)(unitPath("hub", nameOrPort, backend))) {
48892
49108
  const root = readUnitRoot("hub", nameOrPort, backend);
48893
49109
  supervisorStopQuiet("hub", backend, nameOrPort);
48894
49110
  removeUnit("hub", nameOrPort, backend);
@@ -48908,7 +49124,7 @@ machines dial, recreate it with \`--public-address <host:port>\`.`
48908
49124
  const hub = await requireHub(nameOrPort);
48909
49125
  refuseSupervised(hub, "restart");
48910
49126
  const backend = resolveBackend();
48911
- if (backend === "none" || !(0, import_node_fs11.existsSync)(unitPath("hub", hub.name, backend))) {
49127
+ if (backend === "none" || !(0, import_node_fs12.existsSync)(unitPath("hub", hub.name, backend))) {
48912
49128
  fail(
48913
49129
  `"${hub.name}" is not managed by slay, so it cannot be restarted from here. Stop it where it was started, then \`slay hub create ${hub.name}\`.`
48914
49130
  );
@@ -48960,7 +49176,7 @@ then \`slay hub start ${name}\`.`
48960
49176
  root: hub.root,
48961
49177
  lines,
48962
49178
  follow: opts.follow === true,
48963
- systemdUnit: backend === "systemd" && (0, import_node_fs11.existsSync)(unitPath("hub", hub.name, backend))
49179
+ systemdUnit: backend === "systemd" && (0, import_node_fs12.existsSync)(unitPath("hub", hub.name, backend))
48964
49180
  });
48965
49181
  });
48966
49182
  cmd.command("use <name|url>").description("Point this CLI at a hub \u2014 a name from `hub ls`, or a full URL").option("--token <token>", "Bearer token sent as Authorization header").action(async (target, opts) => {
@@ -49090,7 +49306,7 @@ ${target.token ?? ""}`;
49090
49306
 
49091
49307
  // src/commands/computer.ts
49092
49308
  var import_node_child_process6 = require("node:child_process");
49093
- var import_node_fs13 = require("node:fs");
49309
+ var import_node_fs14 = require("node:fs");
49094
49310
  var import_node_path13 = require("node:path");
49095
49311
 
49096
49312
  // ../../shared/platform/src/join-token.ts
@@ -49118,7 +49334,7 @@ function decodeJoinToken(token) {
49118
49334
  }
49119
49335
 
49120
49336
  // src/commands/computer-identity.ts
49121
- var import_node_fs12 = require("node:fs");
49337
+ var import_node_fs13 = require("node:fs");
49122
49338
  var import_node_path12 = require("node:path");
49123
49339
  function configPathFor(root) {
49124
49340
  return (0, import_node_path12.join)(root, "computer.config.json");
@@ -49128,7 +49344,7 @@ function ambientRoot() {
49128
49344
  }
49129
49345
  function isEnrolled(root) {
49130
49346
  try {
49131
- const parsed = JSON.parse((0, import_node_fs12.readFileSync)((0, import_node_path12.join)(root, "computer.state.json"), "utf8"));
49347
+ const parsed = JSON.parse((0, import_node_fs13.readFileSync)((0, import_node_path12.join)(root, "computer.state.json"), "utf8"));
49132
49348
  return typeof parsed === "object" && parsed !== null && Object.keys(parsed).length > 0;
49133
49349
  } catch {
49134
49350
  return false;
@@ -49179,7 +49395,7 @@ function rootClaims(root, name) {
49179
49395
  }
49180
49396
  async function resolveComputer(name, backend, opts = {}) {
49181
49397
  const cwd = opts.cwd ?? ambientRoot();
49182
- const supervised = backend !== "none" && (0, import_node_fs12.existsSync)(unitPath("computer", name, backend));
49398
+ const supervised = backend !== "none" && (0, import_node_fs13.existsSync)(unitPath("computer", name, backend));
49183
49399
  const root = supervised ? readUnitRoot("computer", name, backend) : rootClaims(cwd, name) ? cwd : null;
49184
49400
  const local = localFacts(name, root, backend, supervised);
49185
49401
  if (opts.hub === false) return { ...local, connected: null };
@@ -49206,7 +49422,7 @@ async function listComputers(backend, opts = {}) {
49206
49422
  for (const r of rows ?? []) names.add(r.name);
49207
49423
  const computers = [];
49208
49424
  for (const name of [...names].sort((a, b) => a.localeCompare(b))) {
49209
- const supervised = backend !== "none" && (0, import_node_fs12.existsSync)(unitPath("computer", name, backend));
49425
+ const supervised = backend !== "none" && (0, import_node_fs13.existsSync)(unitPath("computer", name, backend));
49210
49426
  const root = supervised ? readUnitRoot("computer", name, backend) : rootClaims(cwd, name) ? cwd : null;
49211
49427
  const local = localFacts(name, root, backend, supervised);
49212
49428
  const row = rows?.find((r) => r.name === name) ?? null;
@@ -49279,7 +49495,7 @@ function requireRegistered(name, backend) {
49279
49495
  npx ${COMPUTER_PACKAGE}`
49280
49496
  );
49281
49497
  }
49282
- if (!(0, import_node_fs13.existsSync)(unitPath("computer", name, backend))) {
49498
+ if (!(0, import_node_fs14.existsSync)(unitPath("computer", name, backend))) {
49283
49499
  const known = listRegisteredUnits("computer", backend).map((u) => u.name);
49284
49500
  fail(
49285
49501
  `No computer named "${name}" on this machine.
@@ -49309,7 +49525,7 @@ async function launchComputer(args) {
49309
49525
  const logDir = ensureLogDir("computer", root);
49310
49526
  const logs = serviceLogPaths("computer", root);
49311
49527
  if (backend === "none") {
49312
- const out = (0, import_node_fs13.openSync)(logs.out, "a");
49528
+ const out = (0, import_node_fs14.openSync)(logs.out, "a");
49313
49529
  const child = (0, import_node_child_process6.spawn)(bin.command, bin.args, {
49314
49530
  cwd: root,
49315
49531
  detached: true,
@@ -49359,7 +49575,7 @@ async function launchComputer(args) {
49359
49575
  },
49360
49576
  backend
49361
49577
  );
49362
- (0, import_node_fs13.writeFileSync)(
49578
+ (0, import_node_fs14.writeFileSync)(
49363
49579
  (0, import_node_path13.join)(root, "computer-runtime", "host-service.json"),
49364
49580
  JSON.stringify({ backend, name }),
49365
49581
  { mode: 384 }
@@ -49568,7 +49784,7 @@ Mint one on the hub:
49568
49784
  `"${DEFAULT_LOCAL_COMPUTER_NAME}" is reserved for the computer inside the SlayZone desktop app \u2014 a second computer using it would collide with that one on the hub. Choose another name.`
49569
49785
  );
49570
49786
  }
49571
- if (backend !== "none" && (0, import_node_fs13.existsSync)(unitPath("computer", name, backend))) {
49787
+ if (backend !== "none" && (0, import_node_fs14.existsSync)(unitPath("computer", name, backend))) {
49572
49788
  const existingRoot = readUnitRoot("computer", name, backend);
49573
49789
  fail(
49574
49790
  `A computer named "${name}" already exists${existingRoot ? ` (root ${shortenPath(existingRoot)})` : ""}.
@@ -49609,7 +49825,7 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
49609
49825
  );
49610
49826
  if (!adopting) {
49611
49827
  registerCreateRollback(() => {
49612
- (0, import_node_fs13.rmSync)(configPathFor(root), { force: true });
49828
+ (0, import_node_fs14.rmSync)(configPathFor(root), { force: true });
49613
49829
  });
49614
49830
  }
49615
49831
  console.log(`Hub: ${decoded.hubUrl}`);
@@ -49669,7 +49885,7 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
49669
49885
  }
49670
49886
  if (facts.root && facts.installed) {
49671
49887
  if (opts.purge) {
49672
- (0, import_node_fs13.rmSync)(facts.root, { recursive: true, force: true });
49888
+ (0, import_node_fs14.rmSync)(facts.root, { recursive: true, force: true });
49673
49889
  console.log(`Deleted ${shortenPath(facts.root)}.`);
49674
49890
  } else {
49675
49891
  console.log(`Config and credentials remain in ${shortenPath(facts.root)}.`);
@@ -49708,7 +49924,7 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
49708
49924
  supervisorStop("computer", backend, name);
49709
49925
  supervisorStopQuiet("computer-host", backend, name);
49710
49926
  await waitForStopped(name, backend, 15e3);
49711
- if ((0, import_node_fs13.existsSync)(unitPath("computer-host", name, backend)))
49927
+ if ((0, import_node_fs14.existsSync)(unitPath("computer-host", name, backend)))
49712
49928
  supervisorStart("computer-host", backend, name, unitPath("computer-host", name, backend));
49713
49929
  supervisorStart("computer", backend, name, unitPath("computer", name, backend));
49714
49930
  if (!await waitForConnected(root, ENROLL_TIMEOUT_MS, backend, name)) {
@@ -49742,7 +49958,7 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
49742
49958
  const edit = editAllowedRoots(current, {
49743
49959
  add: (opts.add ?? []).map((d) => (0, import_node_path13.resolve)(d)),
49744
49960
  remove: (opts.remove ?? []).map((d) => (0, import_node_path13.resolve)(d)),
49745
- exists: import_node_fs13.existsSync
49961
+ exists: import_node_fs14.existsSync
49746
49962
  });
49747
49963
  if (edit.missing.length > 0) {
49748
49964
  fail(
@@ -49770,7 +49986,7 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
49770
49986
  root,
49771
49987
  lines,
49772
49988
  follow: opts.follow === true,
49773
- systemdUnit: backend === "systemd" && (0, import_node_fs13.existsSync)(unitPath("computer", name, backend))
49989
+ systemdUnit: backend === "systemd" && (0, import_node_fs14.existsSync)(unitPath("computer", name, backend))
49774
49990
  });
49775
49991
  });
49776
49992
  return cmd;
@@ -49778,7 +49994,7 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
49778
49994
 
49779
49995
  // src/commands/update.ts
49780
49996
  var import_node_child_process7 = require("node:child_process");
49781
- var import_node_fs14 = require("node:fs");
49997
+ var import_node_fs15 = require("node:fs");
49782
49998
  var import_node_os3 = require("node:os");
49783
49999
  var import_node_path14 = require("node:path");
49784
50000
  var PACKAGE_NAMES = ["@slayzone/cli", "@slayzone/computer", "@slayzone/hub"];
@@ -49796,7 +50012,7 @@ function runCapture(bin, args) {
49796
50012
  function bunGlobalRoot() {
49797
50013
  const base = process.env.BUN_INSTALL || (0, import_node_path14.join)((0, import_node_os3.homedir)(), ".bun");
49798
50014
  const dir = (0, import_node_path14.join)(base, "install", "global", "node_modules");
49799
- return (0, import_node_fs14.existsSync)(dir) ? dir : null;
50015
+ return (0, import_node_fs15.existsSync)(dir) ? dir : null;
49800
50016
  }
49801
50017
  var MANAGERS = [
49802
50018
  {
@@ -49837,9 +50053,9 @@ var MANAGERS = [
49837
50053
  ];
49838
50054
  function readInstalledVersion(globalRoot, pkg) {
49839
50055
  const pkgJsonPath = (0, import_node_path14.join)(globalRoot, ...pkg.split("/"), "package.json");
49840
- if (!(0, import_node_fs14.existsSync)(pkgJsonPath)) return null;
50056
+ if (!(0, import_node_fs15.existsSync)(pkgJsonPath)) return null;
49841
50057
  try {
49842
- const parsed = JSON.parse((0, import_node_fs14.readFileSync)(pkgJsonPath, "utf8"));
50058
+ const parsed = JSON.parse((0, import_node_fs15.readFileSync)(pkgJsonPath, "utf8"));
49843
50059
  return typeof parsed.version === "string" ? parsed.version : null;
49844
50060
  } catch {
49845
50061
  return null;
@@ -49955,7 +50171,7 @@ function updateCommand() {
49955
50171
  }
49956
50172
 
49957
50173
  // src/index.ts
49958
- var program2 = new Command().name("slay").description("SlayZone CLI").version("0.38.2").option("--dev", "Use development database (slayzone.dev.data.sqlite)").option("--hub <name|port>", "Target a specific hub on this machine (see `slay hub ls`)").showSuggestionAfterError(true).showHelpAfterError(true).hook("preAction", async (thisCommand) => {
50174
+ var program2 = new Command().name("slay").description("SlayZone CLI").version("0.40.0").option("--dev", "Use development database (slayzone.dev.data.sqlite)").option("--hub <name|port>", "Target a specific hub on this machine (see `slay hub ls`)").showSuggestionAfterError(true).showHelpAfterError(true).hook("preAction", async (thisCommand) => {
49959
50175
  const root = thisCommand.parent ?? thisCommand;
49960
50176
  const opts = root.opts();
49961
50177
  if (opts.dev) process.env.SLAYZONE_DEV = "1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slayzone/cli",
3
- "version": "0.38.2",
3
+ "version": "0.40.0",
4
4
  "description": "SlayZone CLI — run, list and target SlayZone hubs; drive tasks, ptys and projects",
5
5
  "license": "GPL-3.0-only",
6
6
  "private": false,