@slayzone/cli 0.38.1 → 0.39.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.
- package/dist/slay.js +251 -89
- 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();
|
|
@@ -17536,18 +17539,25 @@ async function doneAction(idPrefix, opts) {
|
|
|
17536
17539
|
|
|
17537
17540
|
// src/commands/tasks/reset-conversation.ts
|
|
17538
17541
|
async function resetConversationAction(idPrefix, opts) {
|
|
17542
|
+
if (opts.tab !== void 0 && opts.allTabs) {
|
|
17543
|
+
console.error("Pass either --tab or --all-tabs, not both.");
|
|
17544
|
+
process.exit(1);
|
|
17545
|
+
}
|
|
17539
17546
|
idPrefix = await resolveId(idPrefix);
|
|
17540
|
-
const { data } = await apiPost(
|
|
17541
|
-
|
|
17542
|
-
opts.
|
|
17543
|
-
|
|
17547
|
+
const { data } = await apiPost(`/api/tasks/${encodeURIComponent(idPrefix)}/reset-conversation`, {
|
|
17548
|
+
...opts.mode ? { mode: opts.mode } : {},
|
|
17549
|
+
...opts.tab !== void 0 ? { tab: opts.tab } : {},
|
|
17550
|
+
...opts.allTabs ? { allTabs: true } : {}
|
|
17551
|
+
});
|
|
17544
17552
|
const shortId = data.id.slice(0, 8);
|
|
17553
|
+
const tab = data.tab === "all" ? "all tabs" : data.tab === data.id ? "main tab" : `tab ${data.tab.slice(0, 8)}`;
|
|
17545
17554
|
if (data.reset.length === 0) {
|
|
17546
|
-
console.log(`No
|
|
17555
|
+
console.log(`No sessions for ${shortId} (${tab}) \u2014 nothing to reset.`);
|
|
17547
17556
|
return;
|
|
17548
17557
|
}
|
|
17549
17558
|
for (const mode of data.reset) {
|
|
17550
|
-
|
|
17559
|
+
const which = mode.startsWith("*") ? "every agent (applied when its computer connects)" : `mode=${mode}`;
|
|
17560
|
+
console.log(`Reset: ${shortId} ${tab} ${which} (next spawn starts fresh)`);
|
|
17551
17561
|
}
|
|
17552
17562
|
}
|
|
17553
17563
|
|
|
@@ -17713,10 +17723,22 @@ async function archiveAction(idPrefix) {
|
|
|
17713
17723
|
// src/commands/tasks/delete.ts
|
|
17714
17724
|
async function deleteAction(idPrefix) {
|
|
17715
17725
|
const { data, task } = await apiDelete(`/api/tasks/${encodeURIComponent(idPrefix)}`);
|
|
17716
|
-
if (typeof data === "object" && data
|
|
17726
|
+
if (typeof data === "object" && "blocked" in data) {
|
|
17717
17727
|
console.error(`Cannot delete: linked to external provider. Unlink first.`);
|
|
17718
17728
|
process.exit(1);
|
|
17719
17729
|
}
|
|
17730
|
+
if (typeof data === "object" && "incomplete" in data) {
|
|
17731
|
+
console.error(`Deletion is incomplete. Cleanup operation: ${data.erasure.id}`);
|
|
17732
|
+
for (const computer of data.erasure.computers.filter((c) => !c.deleted))
|
|
17733
|
+
console.error(`Data on ${computer.name} has not been deleted yet.`);
|
|
17734
|
+
process.exitCode = 2;
|
|
17735
|
+
return;
|
|
17736
|
+
}
|
|
17737
|
+
if (data !== true) {
|
|
17738
|
+
console.error("Task was not deleted.");
|
|
17739
|
+
process.exitCode = 1;
|
|
17740
|
+
return;
|
|
17741
|
+
}
|
|
17720
17742
|
console.log(`Deleted: ${task.id.slice(0, 8)} ${task.title}`);
|
|
17721
17743
|
}
|
|
17722
17744
|
|
|
@@ -22858,6 +22880,43 @@ Use \`slay tasks artifacts read ${artifactId}\` to get the content, or \`downloa
|
|
|
22858
22880
|
console.log(`Moved: ${data.id.slice(0, 8)} -> ${targetName}`);
|
|
22859
22881
|
}
|
|
22860
22882
|
});
|
|
22883
|
+
cmd.command("move-to-task <destTaskId> [entryIds...]").addHelpText(
|
|
22884
|
+
"after",
|
|
22885
|
+
`
|
|
22886
|
+
Entry IDs are artifact or folder IDs (prefixes ok); a folder moves with everything in it.
|
|
22887
|
+
Examples:
|
|
22888
|
+
slay tasks artifacts move-to-task <dest> --all --from <src>
|
|
22889
|
+
slay tasks artifacts move-to-task <dest> <artifactId> <folderId> --into <destFolderId>`
|
|
22890
|
+
).description(
|
|
22891
|
+
"Move artifacts and folders (with their contents) to another task, keeping ids, versions and artifact: links"
|
|
22892
|
+
).option("--all", "Move every top-level artifact and folder of the source task").option(
|
|
22893
|
+
"--from <taskId>",
|
|
22894
|
+
"Source task (default: the entries' task, or $SLAYZONE_TASK_ID with --all)"
|
|
22895
|
+
).option("--into <folderId>", "Destination folder in the target task (default: top level)").option("--json", "Output as JSON").action(async (destTaskId, entryIds, opts) => {
|
|
22896
|
+
const sourceTaskId = opts.from ?? (opts.all ? process.env.SLAYZONE_TASK_ID : void 0);
|
|
22897
|
+
if (opts.all && !sourceTaskId) {
|
|
22898
|
+
console.error("--all needs --from <taskId> (or $SLAYZONE_TASK_ID)");
|
|
22899
|
+
process.exit(1);
|
|
22900
|
+
}
|
|
22901
|
+
if (!opts.all && entryIds.length === 0) {
|
|
22902
|
+
console.error("Name artifact/folder IDs to move, or pass --all");
|
|
22903
|
+
process.exit(1);
|
|
22904
|
+
}
|
|
22905
|
+
const { data } = await apiPost("/api/artifacts/move", {
|
|
22906
|
+
destTaskId,
|
|
22907
|
+
...sourceTaskId ? { sourceTaskId } : {},
|
|
22908
|
+
entryIds,
|
|
22909
|
+
destFolderId: opts.into ?? null,
|
|
22910
|
+
all: opts.all === true
|
|
22911
|
+
});
|
|
22912
|
+
if (opts.json) {
|
|
22913
|
+
console.log(JSON.stringify(data));
|
|
22914
|
+
} else {
|
|
22915
|
+
console.log(
|
|
22916
|
+
`Moved ${data.artifacts.length} artifact(s), ${data.folders.length} folder(s) -> ${data.destTaskId.slice(0, 8)} ${data.destTaskTitle}`
|
|
22917
|
+
);
|
|
22918
|
+
}
|
|
22919
|
+
});
|
|
22861
22920
|
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
22921
|
"after",
|
|
22863
22922
|
`
|
|
@@ -23119,11 +23178,11 @@ function tasksCommand() {
|
|
|
23119
23178
|
cmd.command("view [id]").description("Show task details (id prefix supported; defaults to $SLAYZONE_TASK_ID)").action(viewAction);
|
|
23120
23179
|
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);
|
|
23121
23180
|
cmd.command("reset-conversation [id]").description(
|
|
23122
|
-
"
|
|
23181
|
+
"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
23182
|
).option(
|
|
23124
23183
|
"--mode <mode>",
|
|
23125
|
-
"Limit to one agent (e.g. claude-code, codex). Default: every agent with a
|
|
23126
|
-
).action(resetConversationAction);
|
|
23184
|
+
"Limit to one agent (e.g. claude-code, codex). Default: every agent with a session in scope."
|
|
23185
|
+
).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
23186
|
cmd.command("update [id]").description("Update a task (id prefix supported; defaults to $SLAYZONE_TASK_ID)").option("--title <title>", "New title").option(
|
|
23128
23187
|
"--description <text>",
|
|
23129
23188
|
"New description (reference task specific artifacts via `[title](artifact:<artifact-id>)`)"
|
|
@@ -45436,6 +45495,8 @@ If useful, you have a toolbox for acting on SlayZone itself. You can:
|
|
|
45436
45495
|
|
|
45437
45496
|
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
45497
|
|
|
45498
|
+
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.
|
|
45499
|
+
|
|
45439
45500
|
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
45501
|
`;
|
|
45441
45502
|
function writeInstructionsToDisk(projectPath, providers) {
|
|
@@ -46806,11 +46867,109 @@ function panelsCommand() {
|
|
|
46806
46867
|
|
|
46807
46868
|
// src/commands/hub.ts
|
|
46808
46869
|
var import_node_child_process5 = require("node:child_process");
|
|
46809
|
-
var
|
|
46870
|
+
var import_node_fs12 = require("node:fs");
|
|
46810
46871
|
var import_node_path11 = require("node:path");
|
|
46811
46872
|
|
|
46812
|
-
//
|
|
46873
|
+
// src/commands/hub-erasure.ts
|
|
46813
46874
|
var import_node_fs6 = require("node:fs");
|
|
46875
|
+
function registerHubErasureCommands(users, accounts, erasure) {
|
|
46876
|
+
async function userId(email3) {
|
|
46877
|
+
const list = await accounts("GET");
|
|
46878
|
+
const user = list.find((u) => u.email.toLowerCase() === email3.trim().toLowerCase());
|
|
46879
|
+
if (!user) throw new Error("User not found on the selected hub.");
|
|
46880
|
+
return user.id;
|
|
46881
|
+
}
|
|
46882
|
+
function show(report, json2) {
|
|
46883
|
+
if (json2) console.log(JSON.stringify(report, null, 2));
|
|
46884
|
+
else {
|
|
46885
|
+
console.log(
|
|
46886
|
+
`${report.state === "complete" ? "SlayZone content erased." : "Some data has not been deleted yet."} Operation: ${report.id}`
|
|
46887
|
+
);
|
|
46888
|
+
for (const computer of report.computers.filter((c) => !c.deleted))
|
|
46889
|
+
console.log(`Data on ${computer.name} has not been deleted yet.`);
|
|
46890
|
+
if (report.failures.length) console.log(`Cleanup failures: ${report.failures.join(", ")}`);
|
|
46891
|
+
}
|
|
46892
|
+
if (report.state !== "complete") process.exitCode = 2;
|
|
46893
|
+
}
|
|
46894
|
+
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) => {
|
|
46895
|
+
const id = await userId(email3);
|
|
46896
|
+
if (opts.confirm === void 0) {
|
|
46897
|
+
const preview = await erasure("GET", void 0, {
|
|
46898
|
+
view: "preview",
|
|
46899
|
+
userId: id
|
|
46900
|
+
});
|
|
46901
|
+
console.log(JSON.stringify(preview, null, 2));
|
|
46902
|
+
if (!opts.json)
|
|
46903
|
+
console.log("Preview only. To erase permanently, repeat with --confirm <selected email>.");
|
|
46904
|
+
return;
|
|
46905
|
+
}
|
|
46906
|
+
if (opts.confirm.trim().toLowerCase() !== email3.trim().toLowerCase())
|
|
46907
|
+
throw new Error("--confirm must match the selected email.");
|
|
46908
|
+
show(
|
|
46909
|
+
await erasure("POST", {
|
|
46910
|
+
action: "erase-content",
|
|
46911
|
+
userId: id,
|
|
46912
|
+
confirmation: opts.confirm
|
|
46913
|
+
}),
|
|
46914
|
+
opts.json
|
|
46915
|
+
);
|
|
46916
|
+
});
|
|
46917
|
+
users.command("erasure-status <email>").description("Show erasure progress and remaining computer copies").option("--json", "Output JSON").action(async (email3, opts) => {
|
|
46918
|
+
const reports = await erasure("GET", void 0, {
|
|
46919
|
+
view: "reports",
|
|
46920
|
+
userId: await userId(email3)
|
|
46921
|
+
});
|
|
46922
|
+
if (opts.json) {
|
|
46923
|
+
console.log(JSON.stringify(reports, null, 2));
|
|
46924
|
+
if (reports.some((report) => report.state === "incomplete")) process.exitCode = 2;
|
|
46925
|
+
return;
|
|
46926
|
+
}
|
|
46927
|
+
if (!reports.length) console.log("No erasure operations recorded.");
|
|
46928
|
+
for (const report of reports) show(report, opts.json);
|
|
46929
|
+
});
|
|
46930
|
+
users.command("retry-erasure <job-id>").description("Resume an already-confirmed erasure").option("--json", "Output JSON").action(
|
|
46931
|
+
async (jobId, opts) => show(await erasure("POST", { action: "retry-erasure", jobId }), opts.json)
|
|
46932
|
+
);
|
|
46933
|
+
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) => {
|
|
46934
|
+
const receipt = await erasure("POST", { action: "receipt", jobId });
|
|
46935
|
+
save(opts.output, receipt);
|
|
46936
|
+
console.log(`Saved erasure receipt: ${opts.output}`);
|
|
46937
|
+
});
|
|
46938
|
+
users.command("computer-erasure-request <job-id> <computer-id>").description("Create an offline cleanup request containing identifiers only").requiredOption(
|
|
46939
|
+
"--computer-hub-url <url>",
|
|
46940
|
+
"The exact URL this computer used, ending in /computers"
|
|
46941
|
+
).requiredOption("--output <path>", "Create a new request file").action(
|
|
46942
|
+
async (jobId, computerId, opts) => {
|
|
46943
|
+
const data = await erasure("POST", {
|
|
46944
|
+
action: "computer-erasure-request",
|
|
46945
|
+
jobId,
|
|
46946
|
+
computerId,
|
|
46947
|
+
hubUrl: opts.computerHubUrl
|
|
46948
|
+
});
|
|
46949
|
+
save(opts.output, data);
|
|
46950
|
+
console.log(`Saved offline cleanup request: ${opts.output}`);
|
|
46951
|
+
}
|
|
46952
|
+
);
|
|
46953
|
+
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) => {
|
|
46954
|
+
const receipt = JSON.parse((0, import_node_fs6.readFileSync)(file2, "utf8"));
|
|
46955
|
+
show(
|
|
46956
|
+
await erasure("POST", { action: "confirm-computer-erasure", receipt }),
|
|
46957
|
+
opts.json
|
|
46958
|
+
);
|
|
46959
|
+
});
|
|
46960
|
+
}
|
|
46961
|
+
function save(path12, value) {
|
|
46962
|
+
(0, import_node_fs6.writeFileSync)(path12, JSON.stringify(value, null, 2) + "\n", { flag: "wx", mode: 384 });
|
|
46963
|
+
const fd = (0, import_node_fs6.openSync)(path12, "r");
|
|
46964
|
+
try {
|
|
46965
|
+
(0, import_node_fs6.fsyncSync)(fd);
|
|
46966
|
+
} finally {
|
|
46967
|
+
(0, import_node_fs6.closeSync)(fd);
|
|
46968
|
+
}
|
|
46969
|
+
}
|
|
46970
|
+
|
|
46971
|
+
// ../../shared/platform/src/slayzone-config.ts
|
|
46972
|
+
var import_node_fs7 = require("node:fs");
|
|
46814
46973
|
var import_node_path7 = require("node:path");
|
|
46815
46974
|
var HUB_CONFIG_SWITCH_KEYS = [
|
|
46816
46975
|
"requireLogin",
|
|
@@ -46871,7 +47030,7 @@ function coerceComputerConfig(raw) {
|
|
|
46871
47030
|
function readJsonObject2(path12) {
|
|
46872
47031
|
let raw;
|
|
46873
47032
|
try {
|
|
46874
|
-
raw = (0,
|
|
47033
|
+
raw = (0, import_node_fs7.readFileSync)(path12, "utf8");
|
|
46875
47034
|
} catch (err) {
|
|
46876
47035
|
if (err.code === "ENOENT") return null;
|
|
46877
47036
|
process.stderr.write(
|
|
@@ -46899,14 +47058,14 @@ function readJsonObject2(path12) {
|
|
|
46899
47058
|
}
|
|
46900
47059
|
function writeJsonAtomic(path12, data) {
|
|
46901
47060
|
const dir = (0, import_node_path7.dirname)(path12);
|
|
46902
|
-
(0,
|
|
47061
|
+
(0, import_node_fs7.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
46903
47062
|
const tmpPath = `${path12}.tmp-${process.pid}-${Date.now()}`;
|
|
46904
|
-
(0,
|
|
47063
|
+
(0, import_node_fs7.writeFileSync)(tmpPath, `${JSON.stringify(data, null, 2)}
|
|
46905
47064
|
`, { mode: 384 });
|
|
46906
47065
|
try {
|
|
46907
|
-
(0,
|
|
47066
|
+
(0, import_node_fs7.renameSync)(tmpPath, path12);
|
|
46908
47067
|
} catch (err) {
|
|
46909
|
-
(0,
|
|
47068
|
+
(0, import_node_fs7.rmSync)(tmpPath, { force: true });
|
|
46910
47069
|
throw err;
|
|
46911
47070
|
}
|
|
46912
47071
|
}
|
|
@@ -46943,7 +47102,7 @@ function updateComputerConfigFile(patch, path12 = getComputerConfigFilePath()) {
|
|
|
46943
47102
|
|
|
46944
47103
|
// ../../shared/platform/src/service-unit.ts
|
|
46945
47104
|
var import_node_child_process2 = require("node:child_process");
|
|
46946
|
-
var
|
|
47105
|
+
var import_node_fs8 = require("node:fs");
|
|
46947
47106
|
var import_node_os2 = require("node:os");
|
|
46948
47107
|
var import_node_path8 = require("node:path");
|
|
46949
47108
|
var KINDS = {
|
|
@@ -46999,7 +47158,7 @@ function derivedRuntimeDir() {
|
|
|
46999
47158
|
const uid = process.getuid?.();
|
|
47000
47159
|
if (uid === void 0) return null;
|
|
47001
47160
|
const dir = `/run/user/${uid}`;
|
|
47002
|
-
return (0,
|
|
47161
|
+
return (0, import_node_fs8.existsSync)(dir) ? dir : null;
|
|
47003
47162
|
}
|
|
47004
47163
|
function userServiceEnv() {
|
|
47005
47164
|
const dir = derivedRuntimeDir();
|
|
@@ -47157,34 +47316,34 @@ WantedBy=default.target
|
|
|
47157
47316
|
}
|
|
47158
47317
|
function writeUnit(spec, backend, unitDir = defaultUnitDir(backend)) {
|
|
47159
47318
|
const path12 = unitPath(spec.kind, spec.name, backend, unitDir);
|
|
47160
|
-
(0,
|
|
47319
|
+
(0, import_node_fs8.mkdirSync)(unitDir, { recursive: true });
|
|
47161
47320
|
const content = backend === "launchd" ? renderLaunchdPlist(spec) : renderSystemdUnit(spec);
|
|
47162
47321
|
if (!unitHoldsSecret(spec)) {
|
|
47163
|
-
(0,
|
|
47322
|
+
(0, import_node_fs8.writeFileSync)(path12, content, { mode: 420 });
|
|
47164
47323
|
return path12;
|
|
47165
47324
|
}
|
|
47166
47325
|
const tmp = `${path12}.${process.pid}.tmp`;
|
|
47167
|
-
(0,
|
|
47326
|
+
(0, import_node_fs8.rmSync)(tmp, { force: true });
|
|
47168
47327
|
try {
|
|
47169
|
-
(0,
|
|
47170
|
-
(0,
|
|
47171
|
-
(0,
|
|
47328
|
+
(0, import_node_fs8.writeFileSync)(tmp, content, { mode: 384, flag: "wx" });
|
|
47329
|
+
(0, import_node_fs8.chmodSync)(tmp, 384);
|
|
47330
|
+
(0, import_node_fs8.renameSync)(tmp, path12);
|
|
47172
47331
|
} catch (err) {
|
|
47173
|
-
(0,
|
|
47332
|
+
(0, import_node_fs8.rmSync)(tmp, { force: true });
|
|
47174
47333
|
throw err;
|
|
47175
47334
|
}
|
|
47176
47335
|
return path12;
|
|
47177
47336
|
}
|
|
47178
47337
|
function removeUnit(kind, name, backend, unitDir = defaultUnitDir(backend)) {
|
|
47179
47338
|
const path12 = unitPath(kind, name, backend, unitDir);
|
|
47180
|
-
if (!(0,
|
|
47181
|
-
(0,
|
|
47339
|
+
if (!(0, import_node_fs8.existsSync)(path12)) return false;
|
|
47340
|
+
(0, import_node_fs8.rmSync)(path12, { force: true });
|
|
47182
47341
|
return true;
|
|
47183
47342
|
}
|
|
47184
47343
|
function listRegisteredUnits(kind, backend, unitDir = defaultUnitDir(backend)) {
|
|
47185
47344
|
let files;
|
|
47186
47345
|
try {
|
|
47187
|
-
files = (0,
|
|
47346
|
+
files = (0, import_node_fs8.readdirSync)(unitDir);
|
|
47188
47347
|
} catch {
|
|
47189
47348
|
return [];
|
|
47190
47349
|
}
|
|
@@ -47198,7 +47357,7 @@ function listRegisteredUnits(kind, backend, unitDir = defaultUnitDir(backend)) {
|
|
|
47198
47357
|
function readUnitRoot(kind, name, backend, unitDir = defaultUnitDir(backend)) {
|
|
47199
47358
|
let text;
|
|
47200
47359
|
try {
|
|
47201
|
-
text = (0,
|
|
47360
|
+
text = (0, import_node_fs8.readFileSync)(unitPath(kind, name, backend, unitDir), "utf8");
|
|
47202
47361
|
} catch {
|
|
47203
47362
|
return null;
|
|
47204
47363
|
}
|
|
@@ -47221,7 +47380,7 @@ function launchdLabel(kind, name) {
|
|
|
47221
47380
|
function readUnitEnv(kind, name, backend, unitDir = defaultUnitDir(backend)) {
|
|
47222
47381
|
let text;
|
|
47223
47382
|
try {
|
|
47224
|
-
text = (0,
|
|
47383
|
+
text = (0, import_node_fs8.readFileSync)(unitPath(kind, name, backend, unitDir), "utf8");
|
|
47225
47384
|
} catch {
|
|
47226
47385
|
return {};
|
|
47227
47386
|
}
|
|
@@ -47246,9 +47405,9 @@ function readUnitSecrets(kind, name, backend, unitDir = defaultUnitDir(backend))
|
|
|
47246
47405
|
}
|
|
47247
47406
|
|
|
47248
47407
|
// ../../shared/platform/src/computer-launcher.ts
|
|
47249
|
-
var import_node_fs8 = require("node:fs");
|
|
47250
|
-
var import_node_path9 = require("node:path");
|
|
47251
47408
|
var import_node_fs9 = require("node:fs");
|
|
47409
|
+
var import_node_path9 = require("node:path");
|
|
47410
|
+
var import_node_fs10 = require("node:fs");
|
|
47252
47411
|
var COMPUTER_LAUNCHER = String.raw`#!/usr/bin/env node
|
|
47253
47412
|
const fs = require('node:fs'), path = require('node:path'), cp = require('node:child_process');
|
|
47254
47413
|
const root = process.env.SLAYZONE_ROOT;
|
|
@@ -47290,9 +47449,9 @@ launch();
|
|
|
47290
47449
|
`;
|
|
47291
47450
|
function ensureComputerLauncher(root, release, forceUpgrade = false) {
|
|
47292
47451
|
const dir = (0, import_node_path9.join)(root, "computer-runtime");
|
|
47293
|
-
(0,
|
|
47452
|
+
(0, import_node_fs9.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
47294
47453
|
const launcher = (0, import_node_path9.join)(dir, "launch.cjs");
|
|
47295
|
-
(0,
|
|
47454
|
+
(0, import_node_fs9.writeFileSync)(launcher + ".tmp", COMPUTER_LAUNCHER, { mode: 448 });
|
|
47296
47455
|
renameLauncher(launcher);
|
|
47297
47456
|
if (forceUpgrade) {
|
|
47298
47457
|
for (const name of ["supervisor.json", "host-release.json"]) {
|
|
@@ -47302,35 +47461,35 @@ function ensureComputerLauncher(root, release, forceUpgrade = false) {
|
|
|
47302
47461
|
previous = JSON.parse(readPointer(path12)).current;
|
|
47303
47462
|
} catch {
|
|
47304
47463
|
}
|
|
47305
|
-
(0,
|
|
47464
|
+
(0, import_node_fs9.writeFileSync)(
|
|
47306
47465
|
path12 + ".tmp",
|
|
47307
47466
|
JSON.stringify({ current: release, ...previous ? { previous } : {} }),
|
|
47308
47467
|
{ mode: 384 }
|
|
47309
47468
|
);
|
|
47310
|
-
(0,
|
|
47469
|
+
(0, import_node_fs10.renameSync)(path12 + ".tmp", path12);
|
|
47311
47470
|
}
|
|
47312
47471
|
}
|
|
47313
47472
|
const hostPointer = (0, import_node_path9.join)(dir, "host-release.json");
|
|
47314
|
-
if (!(0,
|
|
47315
|
-
(0,
|
|
47473
|
+
if (!(0, import_node_fs9.existsSync)(hostPointer))
|
|
47474
|
+
(0, import_node_fs9.writeFileSync)(hostPointer, JSON.stringify({ current: release }), { mode: 384, flag: "wx" });
|
|
47316
47475
|
const pointer = (0, import_node_path9.join)(dir, "supervisor.json");
|
|
47317
|
-
if (!(0,
|
|
47318
|
-
(0,
|
|
47476
|
+
if (!(0, import_node_fs9.existsSync)(pointer))
|
|
47477
|
+
(0, import_node_fs9.writeFileSync)(pointer, JSON.stringify({ current: release }), { mode: 384, flag: "wx" });
|
|
47319
47478
|
return launcher;
|
|
47320
47479
|
}
|
|
47321
47480
|
function readPointer(path12) {
|
|
47322
|
-
return (0,
|
|
47481
|
+
return (0, import_node_fs10.readFileSync)(path12, "utf8");
|
|
47323
47482
|
}
|
|
47324
47483
|
function renameLauncher(path12) {
|
|
47325
|
-
(0,
|
|
47484
|
+
(0, import_node_fs10.renameSync)(path12 + ".tmp", path12);
|
|
47326
47485
|
}
|
|
47327
47486
|
|
|
47328
47487
|
// src/service.ts
|
|
47329
47488
|
var import_node_child_process3 = require("node:child_process");
|
|
47330
|
-
var
|
|
47489
|
+
var import_node_fs11 = require("node:fs");
|
|
47331
47490
|
var import_node_module = require("node:module");
|
|
47332
47491
|
var import_node_path10 = require("node:path");
|
|
47333
|
-
var CLI_VERSION = true ? "0.
|
|
47492
|
+
var CLI_VERSION = true ? "0.39.0" : "";
|
|
47334
47493
|
function fail(message) {
|
|
47335
47494
|
console.error(message);
|
|
47336
47495
|
process.exit(1);
|
|
@@ -47363,25 +47522,25 @@ function servicePackage(kind) {
|
|
|
47363
47522
|
function readServicePkg(kind, pkgJsonPath) {
|
|
47364
47523
|
let pkg;
|
|
47365
47524
|
try {
|
|
47366
|
-
pkg = JSON.parse((0,
|
|
47525
|
+
pkg = JSON.parse((0, import_node_fs11.readFileSync)(pkgJsonPath, "utf8"));
|
|
47367
47526
|
} catch {
|
|
47368
47527
|
return null;
|
|
47369
47528
|
}
|
|
47370
47529
|
const binRel = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.[PACKAGES[kind].bin];
|
|
47371
47530
|
if (!binRel) return null;
|
|
47372
47531
|
const binPath = (0, import_node_path10.join)((0, import_node_path10.dirname)(pkgJsonPath), binRel);
|
|
47373
|
-
if (!(0,
|
|
47532
|
+
if (!(0, import_node_fs11.existsSync)(binPath)) return null;
|
|
47374
47533
|
return { binPath, version: pkg.version ?? "unknown" };
|
|
47375
47534
|
}
|
|
47376
47535
|
function interpreterFor(binPath, version2) {
|
|
47377
47536
|
let dir = (0, import_node_path10.dirname)(binPath);
|
|
47378
47537
|
for (let i = 0; i < 6; i++) {
|
|
47379
47538
|
const pathTxt = (0, import_node_path10.join)(dir, "node_modules", "electron", "path.txt");
|
|
47380
|
-
if ((0,
|
|
47539
|
+
if ((0, import_node_fs11.existsSync)(pathTxt)) {
|
|
47381
47540
|
try {
|
|
47382
|
-
const rel = (0,
|
|
47541
|
+
const rel = (0, import_node_fs11.readFileSync)(pathTxt, "utf8").trim();
|
|
47383
47542
|
const electron = (0, import_node_path10.join)(dir, "node_modules", "electron", "dist", rel);
|
|
47384
|
-
if ((0,
|
|
47543
|
+
if ((0, import_node_fs11.existsSync)(electron)) {
|
|
47385
47544
|
return {
|
|
47386
47545
|
command: electron,
|
|
47387
47546
|
args: [binPath],
|
|
@@ -47433,7 +47592,7 @@ function resolveServiceBin(kind, computerRoot, forceUpgrade = false) {
|
|
|
47433
47592
|
const self2 = process.argv[1];
|
|
47434
47593
|
if (!self2) return null;
|
|
47435
47594
|
const sibling = (0, import_node_path10.join)((0, import_node_path10.dirname)(self2), "..", "..", devDir, "package.json");
|
|
47436
|
-
return (0,
|
|
47595
|
+
return (0, import_node_fs11.existsSync)(sibling) ? sibling : null;
|
|
47437
47596
|
}
|
|
47438
47597
|
];
|
|
47439
47598
|
for (const find of candidates) {
|
|
@@ -47445,9 +47604,9 @@ function resolveServiceBin(kind, computerRoot, forceUpgrade = false) {
|
|
|
47445
47604
|
const prefix = getServiceRuntimeDir(kind);
|
|
47446
47605
|
const installed = (0, import_node_path10.join)(prefix, "node_modules", pkg, "package.json");
|
|
47447
47606
|
const wanted = CLI_VERSION ? `${pkg}@${CLI_VERSION}` : `${pkg}@beta`;
|
|
47448
|
-
if (!(0,
|
|
47607
|
+
if (!(0, import_node_fs11.existsSync)(installed) || CLI_VERSION && readServicePkg(kind, installed)?.version !== CLI_VERSION) {
|
|
47449
47608
|
console.log(`Installing ${wanted}\u2026`);
|
|
47450
|
-
(0,
|
|
47609
|
+
(0, import_node_fs11.mkdirSync)(prefix, { recursive: true });
|
|
47451
47610
|
try {
|
|
47452
47611
|
(0, import_node_child_process3.execFileSync)(
|
|
47453
47612
|
"npm",
|
|
@@ -47472,7 +47631,7 @@ function resolveServiceBin(kind, computerRoot, forceUpgrade = false) {
|
|
|
47472
47631
|
}
|
|
47473
47632
|
function ensureLogDir(kind, root) {
|
|
47474
47633
|
const dir = logDirFor(kind, root);
|
|
47475
|
-
(0,
|
|
47634
|
+
(0, import_node_fs11.mkdirSync)(dir, { recursive: true });
|
|
47476
47635
|
return dir;
|
|
47477
47636
|
}
|
|
47478
47637
|
function logDirFor(_kind, root) {
|
|
@@ -47486,7 +47645,7 @@ function serviceLogPaths(kind, root) {
|
|
|
47486
47645
|
function failWithLog(kind, name, logPath, what) {
|
|
47487
47646
|
let detail = "";
|
|
47488
47647
|
try {
|
|
47489
|
-
detail = (0,
|
|
47648
|
+
detail = (0, import_node_fs11.readFileSync)(logPath, "utf8").trim().split("\n").slice(-12).join("\n");
|
|
47490
47649
|
} catch {
|
|
47491
47650
|
}
|
|
47492
47651
|
const label = kind === "hub" ? "Hub" : "Computer";
|
|
@@ -47515,14 +47674,14 @@ function readServiceLogTail(kind, root, lines, systemdUnit) {
|
|
|
47515
47674
|
const dir = logDirFor(kind, root);
|
|
47516
47675
|
let files;
|
|
47517
47676
|
try {
|
|
47518
|
-
files = (0,
|
|
47677
|
+
files = (0, import_node_fs11.readdirSync)(dir).filter((f) => f.endsWith(".log"));
|
|
47519
47678
|
} catch {
|
|
47520
47679
|
return "";
|
|
47521
47680
|
}
|
|
47522
47681
|
const chunks = [];
|
|
47523
47682
|
for (const f of files) {
|
|
47524
47683
|
try {
|
|
47525
|
-
chunks.push((0,
|
|
47684
|
+
chunks.push((0, import_node_fs11.readFileSync)((0, import_node_path10.join)(dir, f), "utf8"));
|
|
47526
47685
|
} catch {
|
|
47527
47686
|
}
|
|
47528
47687
|
}
|
|
@@ -47538,8 +47697,8 @@ function followServiceLog(args) {
|
|
|
47538
47697
|
return;
|
|
47539
47698
|
}
|
|
47540
47699
|
const dir = logDirFor(kind, root);
|
|
47541
|
-
if (!(0,
|
|
47542
|
-
const candidates = (0,
|
|
47700
|
+
if (!(0, import_node_fs11.existsSync)(dir)) fail(`No log directory at ${shortenPath(dir)}.`);
|
|
47701
|
+
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
47702
|
if (candidates.length === 0) fail(`No log files in ${shortenPath(dir)}.`);
|
|
47544
47703
|
const target = candidates[0].path;
|
|
47545
47704
|
const targs = follow ? ["-f", "-n", String(lines), target] : ["-n", String(lines), target];
|
|
@@ -48416,7 +48575,7 @@ async function launchHub(args) {
|
|
|
48416
48575
|
const probePort = address !== void 0 ? parseHubAddress(address)?.port : port;
|
|
48417
48576
|
const findIt = () => probePort === void 0 ? findAnyHub(name) : findHub(String(probePort));
|
|
48418
48577
|
if (backend === "none") {
|
|
48419
|
-
const out = (0,
|
|
48578
|
+
const out = (0, import_node_fs12.openSync)(logs.out, "a");
|
|
48420
48579
|
const child = (0, import_node_child_process5.spawn)(bin.command, bin.args, {
|
|
48421
48580
|
cwd: root,
|
|
48422
48581
|
detached: true,
|
|
@@ -48523,7 +48682,7 @@ then log out and back in, and retry. If this account is not meant to have one (a
|
|
|
48523
48682
|
}
|
|
48524
48683
|
}
|
|
48525
48684
|
async function haltHub(hub, backend, opts) {
|
|
48526
|
-
if (backend !== "none" && (0,
|
|
48685
|
+
if (backend !== "none" && (0, import_node_fs12.existsSync)(unitPath("hub", hub.name, backend))) {
|
|
48527
48686
|
supervisorStop("hub", backend, hub.name);
|
|
48528
48687
|
if (opts.unregister) removeUnit("hub", hub.name, backend);
|
|
48529
48688
|
} else {
|
|
@@ -48546,19 +48705,22 @@ async function readPasswordFromStdin() {
|
|
|
48546
48705
|
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
48547
48706
|
return Buffer.concat(chunks).toString("utf8").replace(/\r?\n$/, "");
|
|
48548
48707
|
}
|
|
48549
|
-
function
|
|
48550
|
-
return resolveHubRequestTarget("hub users \u2026", discoverAllHubs).then(
|
|
48708
|
+
function hubUsersRouteRequest(path12) {
|
|
48709
|
+
return (method, body, query) => resolveHubRequestTarget("hub users \u2026", discoverAllHubs).then(
|
|
48551
48710
|
(target) => hubRequest({
|
|
48552
48711
|
target,
|
|
48553
|
-
path: "
|
|
48712
|
+
path: path12 + (query ? "?" + new URLSearchParams(query).toString() : ""),
|
|
48554
48713
|
method,
|
|
48555
48714
|
...body === void 0 ? {} : { body },
|
|
48556
48715
|
unwrap: "data"
|
|
48557
48716
|
})
|
|
48558
48717
|
);
|
|
48559
48718
|
}
|
|
48719
|
+
var hubUsersRequest = hubUsersRouteRequest("/api/hub/users");
|
|
48720
|
+
var hubContentErasureRequest = hubUsersRouteRequest("/api/hub/content-erasure");
|
|
48560
48721
|
function hubUsersCommand() {
|
|
48561
48722
|
const users = new Command("users").description("Manage the accounts that can sign in to a hub").showSuggestionAfterError(true).showHelpAfterError(true);
|
|
48723
|
+
registerHubErasureCommands(users, hubUsersRequest, hubContentErasureRequest);
|
|
48562
48724
|
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
48725
|
const created = await hubUsersRequest("POST", {
|
|
48564
48726
|
email: email3,
|
|
@@ -48770,7 +48932,7 @@ It is written into the hub's service unit (owner-only, 0600) so the hub keeps it
|
|
|
48770
48932
|
);
|
|
48771
48933
|
}
|
|
48772
48934
|
const backend = resolveBackend();
|
|
48773
|
-
if (backend !== "none" && (0,
|
|
48935
|
+
if (backend !== "none" && (0, import_node_fs12.existsSync)(unitPath("hub", name, backend))) {
|
|
48774
48936
|
const existingRoot = readUnitRoot("hub", name, backend);
|
|
48775
48937
|
fail(
|
|
48776
48938
|
`A hub named "${name}" already exists${existingRoot ? ` (root ${shortenPath(existingRoot)})` : ""}.
|
|
@@ -48855,7 +49017,7 @@ machines dial, recreate it with \`--public-address <host:port>\`.`
|
|
|
48855
49017
|
`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
49018
|
);
|
|
48857
49019
|
}
|
|
48858
|
-
if (!(0,
|
|
49020
|
+
if (!(0, import_node_fs12.existsSync)(unitPath("hub", name, backend))) {
|
|
48859
49021
|
fail(
|
|
48860
49022
|
`No hub named "${name}". Create it with \`slay hub create ${name}\`, or list what exists with \`slay hub registered\`.`
|
|
48861
49023
|
);
|
|
@@ -48878,7 +49040,7 @@ machines dial, recreate it with \`--public-address <host:port>\`.`
|
|
|
48878
49040
|
const hub = await requireHub(nameOrPort);
|
|
48879
49041
|
refuseSupervised(hub, "stop");
|
|
48880
49042
|
const backend = resolveBackend();
|
|
48881
|
-
const registered = backend !== "none" && (0,
|
|
49043
|
+
const registered = backend !== "none" && (0, import_node_fs12.existsSync)(unitPath("hub", hub.name, backend));
|
|
48882
49044
|
await haltHub(hub, backend, { unregister: false });
|
|
48883
49045
|
console.log(
|
|
48884
49046
|
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 +49050,7 @@ machines dial, recreate it with \`--public-address <host:port>\`.`
|
|
|
48888
49050
|
const backend = resolveBackend();
|
|
48889
49051
|
const hub = await findAnyHub(nameOrPort);
|
|
48890
49052
|
if (!hub) {
|
|
48891
|
-
if (backend !== "none" && (0,
|
|
49053
|
+
if (backend !== "none" && (0, import_node_fs12.existsSync)(unitPath("hub", nameOrPort, backend))) {
|
|
48892
49054
|
const root = readUnitRoot("hub", nameOrPort, backend);
|
|
48893
49055
|
supervisorStopQuiet("hub", backend, nameOrPort);
|
|
48894
49056
|
removeUnit("hub", nameOrPort, backend);
|
|
@@ -48908,7 +49070,7 @@ machines dial, recreate it with \`--public-address <host:port>\`.`
|
|
|
48908
49070
|
const hub = await requireHub(nameOrPort);
|
|
48909
49071
|
refuseSupervised(hub, "restart");
|
|
48910
49072
|
const backend = resolveBackend();
|
|
48911
|
-
if (backend === "none" || !(0,
|
|
49073
|
+
if (backend === "none" || !(0, import_node_fs12.existsSync)(unitPath("hub", hub.name, backend))) {
|
|
48912
49074
|
fail(
|
|
48913
49075
|
`"${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
49076
|
);
|
|
@@ -48960,7 +49122,7 @@ then \`slay hub start ${name}\`.`
|
|
|
48960
49122
|
root: hub.root,
|
|
48961
49123
|
lines,
|
|
48962
49124
|
follow: opts.follow === true,
|
|
48963
|
-
systemdUnit: backend === "systemd" && (0,
|
|
49125
|
+
systemdUnit: backend === "systemd" && (0, import_node_fs12.existsSync)(unitPath("hub", hub.name, backend))
|
|
48964
49126
|
});
|
|
48965
49127
|
});
|
|
48966
49128
|
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 +49252,7 @@ ${target.token ?? ""}`;
|
|
|
49090
49252
|
|
|
49091
49253
|
// src/commands/computer.ts
|
|
49092
49254
|
var import_node_child_process6 = require("node:child_process");
|
|
49093
|
-
var
|
|
49255
|
+
var import_node_fs14 = require("node:fs");
|
|
49094
49256
|
var import_node_path13 = require("node:path");
|
|
49095
49257
|
|
|
49096
49258
|
// ../../shared/platform/src/join-token.ts
|
|
@@ -49118,7 +49280,7 @@ function decodeJoinToken(token) {
|
|
|
49118
49280
|
}
|
|
49119
49281
|
|
|
49120
49282
|
// src/commands/computer-identity.ts
|
|
49121
|
-
var
|
|
49283
|
+
var import_node_fs13 = require("node:fs");
|
|
49122
49284
|
var import_node_path12 = require("node:path");
|
|
49123
49285
|
function configPathFor(root) {
|
|
49124
49286
|
return (0, import_node_path12.join)(root, "computer.config.json");
|
|
@@ -49128,7 +49290,7 @@ function ambientRoot() {
|
|
|
49128
49290
|
}
|
|
49129
49291
|
function isEnrolled(root) {
|
|
49130
49292
|
try {
|
|
49131
|
-
const parsed = JSON.parse((0,
|
|
49293
|
+
const parsed = JSON.parse((0, import_node_fs13.readFileSync)((0, import_node_path12.join)(root, "computer.state.json"), "utf8"));
|
|
49132
49294
|
return typeof parsed === "object" && parsed !== null && Object.keys(parsed).length > 0;
|
|
49133
49295
|
} catch {
|
|
49134
49296
|
return false;
|
|
@@ -49179,7 +49341,7 @@ function rootClaims(root, name) {
|
|
|
49179
49341
|
}
|
|
49180
49342
|
async function resolveComputer(name, backend, opts = {}) {
|
|
49181
49343
|
const cwd = opts.cwd ?? ambientRoot();
|
|
49182
|
-
const supervised = backend !== "none" && (0,
|
|
49344
|
+
const supervised = backend !== "none" && (0, import_node_fs13.existsSync)(unitPath("computer", name, backend));
|
|
49183
49345
|
const root = supervised ? readUnitRoot("computer", name, backend) : rootClaims(cwd, name) ? cwd : null;
|
|
49184
49346
|
const local = localFacts(name, root, backend, supervised);
|
|
49185
49347
|
if (opts.hub === false) return { ...local, connected: null };
|
|
@@ -49206,7 +49368,7 @@ async function listComputers(backend, opts = {}) {
|
|
|
49206
49368
|
for (const r of rows ?? []) names.add(r.name);
|
|
49207
49369
|
const computers = [];
|
|
49208
49370
|
for (const name of [...names].sort((a, b) => a.localeCompare(b))) {
|
|
49209
|
-
const supervised = backend !== "none" && (0,
|
|
49371
|
+
const supervised = backend !== "none" && (0, import_node_fs13.existsSync)(unitPath("computer", name, backend));
|
|
49210
49372
|
const root = supervised ? readUnitRoot("computer", name, backend) : rootClaims(cwd, name) ? cwd : null;
|
|
49211
49373
|
const local = localFacts(name, root, backend, supervised);
|
|
49212
49374
|
const row = rows?.find((r) => r.name === name) ?? null;
|
|
@@ -49279,7 +49441,7 @@ function requireRegistered(name, backend) {
|
|
|
49279
49441
|
npx ${COMPUTER_PACKAGE}`
|
|
49280
49442
|
);
|
|
49281
49443
|
}
|
|
49282
|
-
if (!(0,
|
|
49444
|
+
if (!(0, import_node_fs14.existsSync)(unitPath("computer", name, backend))) {
|
|
49283
49445
|
const known = listRegisteredUnits("computer", backend).map((u) => u.name);
|
|
49284
49446
|
fail(
|
|
49285
49447
|
`No computer named "${name}" on this machine.
|
|
@@ -49309,7 +49471,7 @@ async function launchComputer(args) {
|
|
|
49309
49471
|
const logDir = ensureLogDir("computer", root);
|
|
49310
49472
|
const logs = serviceLogPaths("computer", root);
|
|
49311
49473
|
if (backend === "none") {
|
|
49312
|
-
const out = (0,
|
|
49474
|
+
const out = (0, import_node_fs14.openSync)(logs.out, "a");
|
|
49313
49475
|
const child = (0, import_node_child_process6.spawn)(bin.command, bin.args, {
|
|
49314
49476
|
cwd: root,
|
|
49315
49477
|
detached: true,
|
|
@@ -49359,7 +49521,7 @@ async function launchComputer(args) {
|
|
|
49359
49521
|
},
|
|
49360
49522
|
backend
|
|
49361
49523
|
);
|
|
49362
|
-
(0,
|
|
49524
|
+
(0, import_node_fs14.writeFileSync)(
|
|
49363
49525
|
(0, import_node_path13.join)(root, "computer-runtime", "host-service.json"),
|
|
49364
49526
|
JSON.stringify({ backend, name }),
|
|
49365
49527
|
{ mode: 384 }
|
|
@@ -49568,7 +49730,7 @@ Mint one on the hub:
|
|
|
49568
49730
|
`"${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
49731
|
);
|
|
49570
49732
|
}
|
|
49571
|
-
if (backend !== "none" && (0,
|
|
49733
|
+
if (backend !== "none" && (0, import_node_fs14.existsSync)(unitPath("computer", name, backend))) {
|
|
49572
49734
|
const existingRoot = readUnitRoot("computer", name, backend);
|
|
49573
49735
|
fail(
|
|
49574
49736
|
`A computer named "${name}" already exists${existingRoot ? ` (root ${shortenPath(existingRoot)})` : ""}.
|
|
@@ -49609,7 +49771,7 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
|
|
|
49609
49771
|
);
|
|
49610
49772
|
if (!adopting) {
|
|
49611
49773
|
registerCreateRollback(() => {
|
|
49612
|
-
(0,
|
|
49774
|
+
(0, import_node_fs14.rmSync)(configPathFor(root), { force: true });
|
|
49613
49775
|
});
|
|
49614
49776
|
}
|
|
49615
49777
|
console.log(`Hub: ${decoded.hubUrl}`);
|
|
@@ -49669,7 +49831,7 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
|
|
|
49669
49831
|
}
|
|
49670
49832
|
if (facts.root && facts.installed) {
|
|
49671
49833
|
if (opts.purge) {
|
|
49672
|
-
(0,
|
|
49834
|
+
(0, import_node_fs14.rmSync)(facts.root, { recursive: true, force: true });
|
|
49673
49835
|
console.log(`Deleted ${shortenPath(facts.root)}.`);
|
|
49674
49836
|
} else {
|
|
49675
49837
|
console.log(`Config and credentials remain in ${shortenPath(facts.root)}.`);
|
|
@@ -49708,7 +49870,7 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
|
|
|
49708
49870
|
supervisorStop("computer", backend, name);
|
|
49709
49871
|
supervisorStopQuiet("computer-host", backend, name);
|
|
49710
49872
|
await waitForStopped(name, backend, 15e3);
|
|
49711
|
-
if ((0,
|
|
49873
|
+
if ((0, import_node_fs14.existsSync)(unitPath("computer-host", name, backend)))
|
|
49712
49874
|
supervisorStart("computer-host", backend, name, unitPath("computer-host", name, backend));
|
|
49713
49875
|
supervisorStart("computer", backend, name, unitPath("computer", name, backend));
|
|
49714
49876
|
if (!await waitForConnected(root, ENROLL_TIMEOUT_MS, backend, name)) {
|
|
@@ -49742,7 +49904,7 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
|
|
|
49742
49904
|
const edit = editAllowedRoots(current, {
|
|
49743
49905
|
add: (opts.add ?? []).map((d) => (0, import_node_path13.resolve)(d)),
|
|
49744
49906
|
remove: (opts.remove ?? []).map((d) => (0, import_node_path13.resolve)(d)),
|
|
49745
|
-
exists:
|
|
49907
|
+
exists: import_node_fs14.existsSync
|
|
49746
49908
|
});
|
|
49747
49909
|
if (edit.missing.length > 0) {
|
|
49748
49910
|
fail(
|
|
@@ -49770,7 +49932,7 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
|
|
|
49770
49932
|
root,
|
|
49771
49933
|
lines,
|
|
49772
49934
|
follow: opts.follow === true,
|
|
49773
|
-
systemdUnit: backend === "systemd" && (0,
|
|
49935
|
+
systemdUnit: backend === "systemd" && (0, import_node_fs14.existsSync)(unitPath("computer", name, backend))
|
|
49774
49936
|
});
|
|
49775
49937
|
});
|
|
49776
49938
|
return cmd;
|
|
@@ -49778,7 +49940,7 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
|
|
|
49778
49940
|
|
|
49779
49941
|
// src/commands/update.ts
|
|
49780
49942
|
var import_node_child_process7 = require("node:child_process");
|
|
49781
|
-
var
|
|
49943
|
+
var import_node_fs15 = require("node:fs");
|
|
49782
49944
|
var import_node_os3 = require("node:os");
|
|
49783
49945
|
var import_node_path14 = require("node:path");
|
|
49784
49946
|
var PACKAGE_NAMES = ["@slayzone/cli", "@slayzone/computer", "@slayzone/hub"];
|
|
@@ -49796,7 +49958,7 @@ function runCapture(bin, args) {
|
|
|
49796
49958
|
function bunGlobalRoot() {
|
|
49797
49959
|
const base = process.env.BUN_INSTALL || (0, import_node_path14.join)((0, import_node_os3.homedir)(), ".bun");
|
|
49798
49960
|
const dir = (0, import_node_path14.join)(base, "install", "global", "node_modules");
|
|
49799
|
-
return (0,
|
|
49961
|
+
return (0, import_node_fs15.existsSync)(dir) ? dir : null;
|
|
49800
49962
|
}
|
|
49801
49963
|
var MANAGERS = [
|
|
49802
49964
|
{
|
|
@@ -49837,9 +49999,9 @@ var MANAGERS = [
|
|
|
49837
49999
|
];
|
|
49838
50000
|
function readInstalledVersion(globalRoot, pkg) {
|
|
49839
50001
|
const pkgJsonPath = (0, import_node_path14.join)(globalRoot, ...pkg.split("/"), "package.json");
|
|
49840
|
-
if (!(0,
|
|
50002
|
+
if (!(0, import_node_fs15.existsSync)(pkgJsonPath)) return null;
|
|
49841
50003
|
try {
|
|
49842
|
-
const parsed = JSON.parse((0,
|
|
50004
|
+
const parsed = JSON.parse((0, import_node_fs15.readFileSync)(pkgJsonPath, "utf8"));
|
|
49843
50005
|
return typeof parsed.version === "string" ? parsed.version : null;
|
|
49844
50006
|
} catch {
|
|
49845
50007
|
return null;
|
|
@@ -49955,7 +50117,7 @@ function updateCommand() {
|
|
|
49955
50117
|
}
|
|
49956
50118
|
|
|
49957
50119
|
// src/index.ts
|
|
49958
|
-
var program2 = new Command().name("slay").description("SlayZone CLI").version("0.
|
|
50120
|
+
var program2 = new Command().name("slay").description("SlayZone CLI").version("0.39.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
50121
|
const root = thisCommand.parent ?? thisCommand;
|
|
49960
50122
|
const opts = root.opts();
|
|
49961
50123
|
if (opts.dev) process.env.SLAYZONE_DEV = "1";
|