@slayzone/cli 0.38.0 → 0.38.2
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 +248 -183
- package/package.json +1 -1
package/dist/slay.js
CHANGED
|
@@ -315,7 +315,7 @@ var require_BufferList = __commonJS({
|
|
|
315
315
|
this.head = this.tail = null;
|
|
316
316
|
this.length = 0;
|
|
317
317
|
};
|
|
318
|
-
BufferList.prototype.join = function
|
|
318
|
+
BufferList.prototype.join = function join11(s) {
|
|
319
319
|
if (this.length === 0) return "";
|
|
320
320
|
var p = this.head;
|
|
321
321
|
var ret = "" + p.data;
|
|
@@ -12670,7 +12670,7 @@ var require_extract = __commonJS({
|
|
|
12670
12670
|
// ../../../node_modules/tar-stream/constants.js
|
|
12671
12671
|
var require_constants = __commonJS({
|
|
12672
12672
|
"../../../node_modules/tar-stream/constants.js"(exports2, module2) {
|
|
12673
|
-
var
|
|
12673
|
+
var constants2 = {
|
|
12674
12674
|
// just for envs without fs
|
|
12675
12675
|
S_IFMT: 61440,
|
|
12676
12676
|
S_IFDIR: 16384,
|
|
@@ -12680,9 +12680,9 @@ var require_constants = __commonJS({
|
|
|
12680
12680
|
S_IFLNK: 40960
|
|
12681
12681
|
};
|
|
12682
12682
|
try {
|
|
12683
|
-
module2.exports = require("fs").constants ||
|
|
12683
|
+
module2.exports = require("fs").constants || constants2;
|
|
12684
12684
|
} catch {
|
|
12685
|
-
module2.exports =
|
|
12685
|
+
module2.exports = constants2;
|
|
12686
12686
|
}
|
|
12687
12687
|
}
|
|
12688
12688
|
});
|
|
@@ -12692,7 +12692,7 @@ var require_pack = __commonJS({
|
|
|
12692
12692
|
"../../../node_modules/tar-stream/pack.js"(exports2, module2) {
|
|
12693
12693
|
var { Readable: Readable3, Writable, getStreamError } = require_streamx();
|
|
12694
12694
|
var b4a = require_b4a();
|
|
12695
|
-
var
|
|
12695
|
+
var constants2 = require_constants();
|
|
12696
12696
|
var headers = require_headers();
|
|
12697
12697
|
var DMODE = 493;
|
|
12698
12698
|
var FMODE = 420;
|
|
@@ -12895,16 +12895,16 @@ var require_pack = __commonJS({
|
|
|
12895
12895
|
return new Pack(opts);
|
|
12896
12896
|
};
|
|
12897
12897
|
function modeToType(mode) {
|
|
12898
|
-
switch (mode &
|
|
12899
|
-
case
|
|
12898
|
+
switch (mode & constants2.S_IFMT) {
|
|
12899
|
+
case constants2.S_IFBLK:
|
|
12900
12900
|
return "block-device";
|
|
12901
|
-
case
|
|
12901
|
+
case constants2.S_IFCHR:
|
|
12902
12902
|
return "character-device";
|
|
12903
|
-
case
|
|
12903
|
+
case constants2.S_IFDIR:
|
|
12904
12904
|
return "directory";
|
|
12905
|
-
case
|
|
12905
|
+
case constants2.S_IFIFO:
|
|
12906
12906
|
return "fifo";
|
|
12907
|
-
case
|
|
12907
|
+
case constants2.S_IFLNK:
|
|
12908
12908
|
return "symlink";
|
|
12909
12909
|
}
|
|
12910
12910
|
return "file";
|
|
@@ -16378,6 +16378,21 @@ var HUB_SSO_ENV = {
|
|
|
16378
16378
|
/** `0|1`, default `1`: refuse a sign-in whose ID token's `amr` does not contain `mfa`. */
|
|
16379
16379
|
requireMfa: "SLAYZONE_HUB_SSO_REQUIRE_MFA"
|
|
16380
16380
|
};
|
|
16381
|
+
var HUB_OIDC_ENV = {
|
|
16382
|
+
/** The issuer, exactly as its tokens' `iss` (discovery: `<issuer>/.well-known/openid-configuration`). */
|
|
16383
|
+
issuer: "SLAYZONE_HUB_OIDC_ISSUER",
|
|
16384
|
+
clientId: "SLAYZONE_HUB_OIDC_CLIENT_ID",
|
|
16385
|
+
/** `client_secret_basic`. Env only, never in hub.config.json. */
|
|
16386
|
+
clientSecret: "SLAYZONE_HUB_OIDC_CLIENT_SECRET",
|
|
16387
|
+
/** Space-separated; default `openid profile email offline_access`. */
|
|
16388
|
+
scopes: "SLAYZONE_HUB_OIDC_SCOPES"
|
|
16389
|
+
};
|
|
16390
|
+
var IDP_ROLE_ENV = {
|
|
16391
|
+
enabled: "IDP_ROLES_ENABLED",
|
|
16392
|
+
claim: "IDP_ROLE_CLAIM",
|
|
16393
|
+
mapping: "IDP_ROLE_MAPPING",
|
|
16394
|
+
recheckIntervalSeconds: "IDP_RECHECK_INTERVAL_SECONDS"
|
|
16395
|
+
};
|
|
16381
16396
|
var RETIRED_HUB_SSO_CLIENT_SECRET_ENV = "SLAYZONE_HUB_SSO_CLIENT_SECRET";
|
|
16382
16397
|
var HUB_ADDRESS_ENV = {
|
|
16383
16398
|
/** Where the hub LISTENS. Renamed from `SLAYZONE_HUB_ADDRESS`, which now only
|
|
@@ -16393,16 +16408,20 @@ var HUB_SESSION_RETENTION_DAYS_ENV = "SLAYZONE_HUB_SESSION_RETENTION_DAYS";
|
|
|
16393
16408
|
var HUB_ALLOWED_WEB_ORIGINS_ENV = "SLAYZONE_HUB_ALLOWED_WEB_ORIGINS";
|
|
16394
16409
|
var HUB_TRUSTED_PROXIES_ENV = "SLAYZONE_HUB_TRUSTED_PROXIES";
|
|
16395
16410
|
var HUB_CONVEX_ADDRESS_ENV = "SLAYZONE_HUB_CONVEX_ADDRESS";
|
|
16411
|
+
var HUB_STUN_ADDRESSES_ENV = "SLAYZONE_HUB_STUN_ADDRESSES";
|
|
16396
16412
|
var HUB_PROCESS_ENV = [
|
|
16397
16413
|
...Object.values(HUB_SWITCH_ENV),
|
|
16398
16414
|
...Object.values(HUB_SSO_ENV),
|
|
16415
|
+
...Object.values(HUB_OIDC_ENV),
|
|
16416
|
+
...Object.values(IDP_ROLE_ENV),
|
|
16399
16417
|
RETIRED_HUB_SSO_CLIENT_SECRET_ENV,
|
|
16400
16418
|
...Object.values(HUB_ADDRESS_ENV),
|
|
16401
16419
|
LEGACY_HUB_LISTEN_ENV,
|
|
16402
16420
|
HUB_ALLOWED_WEB_ORIGINS_ENV,
|
|
16403
16421
|
HUB_TRUSTED_PROXIES_ENV,
|
|
16404
16422
|
HUB_SESSION_RETENTION_DAYS_ENV,
|
|
16405
|
-
HUB_CONVEX_ADDRESS_ENV
|
|
16423
|
+
HUB_CONVEX_ADDRESS_ENV,
|
|
16424
|
+
HUB_STUN_ADDRESSES_ENV
|
|
16406
16425
|
];
|
|
16407
16426
|
|
|
16408
16427
|
// ../../shared/platform/src/paths.ts
|
|
@@ -16678,6 +16697,53 @@ var VARIABLES = {
|
|
|
16678
16697
|
// ../../shared/platform/src/cli-install.ts
|
|
16679
16698
|
var import_child_process = require("child_process");
|
|
16680
16699
|
var import_util = require("util");
|
|
16700
|
+
|
|
16701
|
+
// ../../shared/platform/src/resolve-command.ts
|
|
16702
|
+
var import_node_fs2 = require("node:fs");
|
|
16703
|
+
var import_node_path3 = require("node:path");
|
|
16704
|
+
function isExecutableFile(file2, platform) {
|
|
16705
|
+
try {
|
|
16706
|
+
if (!(0, import_node_fs2.statSync)(file2).isFile()) return false;
|
|
16707
|
+
if (platform !== "win32") (0, import_node_fs2.accessSync)(file2, import_node_fs2.constants.X_OK);
|
|
16708
|
+
return true;
|
|
16709
|
+
} catch {
|
|
16710
|
+
return false;
|
|
16711
|
+
}
|
|
16712
|
+
}
|
|
16713
|
+
function resolveCommand(command, env, cwd, platform = process.platform) {
|
|
16714
|
+
const win = platform === "win32";
|
|
16715
|
+
const suffixes = win ? [
|
|
16716
|
+
...(env.PATHEXT ?? process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean),
|
|
16717
|
+
""
|
|
16718
|
+
] : [""];
|
|
16719
|
+
const hasDir = command.includes("/") || win && command.includes("\\");
|
|
16720
|
+
const found2 = (base) => suffixes.map((s) => base + s).find((p) => isExecutableFile(p, platform)) ?? null;
|
|
16721
|
+
if (hasDir) return found2((0, import_node_path3.isAbsolute)(command) ? command : (0, import_node_path3.join)(cwd ?? process.cwd(), command));
|
|
16722
|
+
for (const dir of (env.PATH ?? env.Path ?? "").split(win ? ";" : import_node_path3.delimiter)) {
|
|
16723
|
+
if (!dir) continue;
|
|
16724
|
+
const hit = found2((0, import_node_path3.join)(dir, command));
|
|
16725
|
+
if (hit) return hit;
|
|
16726
|
+
}
|
|
16727
|
+
return null;
|
|
16728
|
+
}
|
|
16729
|
+
var RESOLVER_CACHE_SIZE = 16;
|
|
16730
|
+
function createCommandResolver(command, platform = process.platform) {
|
|
16731
|
+
const cache = /* @__PURE__ */ new Map();
|
|
16732
|
+
return (env = process.env) => {
|
|
16733
|
+
const pathList = env.PATH ?? env.Path ?? "";
|
|
16734
|
+
const cached2 = cache.get(pathList);
|
|
16735
|
+
if (cached2 && isExecutableFile(cached2, platform)) return cached2;
|
|
16736
|
+
cache.delete(pathList);
|
|
16737
|
+
const found2 = resolveCommand(command, env, void 0, platform);
|
|
16738
|
+
if (!found2 || platform === "win32" && !/\.(exe|com)$/i.test(found2)) return command;
|
|
16739
|
+
if (cache.size >= RESOLVER_CACHE_SIZE) cache.delete(cache.keys().next().value);
|
|
16740
|
+
cache.set(pathList, found2);
|
|
16741
|
+
return found2;
|
|
16742
|
+
};
|
|
16743
|
+
}
|
|
16744
|
+
var gitCommand = createCommandResolver("git");
|
|
16745
|
+
|
|
16746
|
+
// ../../shared/platform/src/cli-install.ts
|
|
16681
16747
|
var execFileAsync = (0, import_util.promisify)(import_child_process.execFile);
|
|
16682
16748
|
var WINDOWS_SHIM = [
|
|
16683
16749
|
"@echo off",
|
|
@@ -16892,7 +16958,7 @@ function unlinkIfPresent(file2) {
|
|
|
16892
16958
|
}
|
|
16893
16959
|
|
|
16894
16960
|
// src/local-hub.ts
|
|
16895
|
-
var
|
|
16961
|
+
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
16896
16962
|
function fixedPortForChannel(dev = isDevChannel()) {
|
|
16897
16963
|
return dev ? SIDECAR_FIXED_PORT.dev : SIDECAR_FIXED_PORT.prod;
|
|
16898
16964
|
}
|
|
@@ -16901,7 +16967,7 @@ function isDevChannel() {
|
|
|
16901
16967
|
}
|
|
16902
16968
|
function identityFor(dev) {
|
|
16903
16969
|
const own2 = process.env.SLAYZONE_ROOT?.trim();
|
|
16904
|
-
if (own2) return dev === isDevChannel() ? { kind: "root", root:
|
|
16970
|
+
if (own2) return dev === isDevChannel() ? { kind: "root", root: import_node_path4.default.resolve(own2) } : null;
|
|
16905
16971
|
const user = currentOsUser();
|
|
16906
16972
|
return user ? { kind: "user", user, dev } : null;
|
|
16907
16973
|
}
|
|
@@ -16909,11 +16975,11 @@ function describeIdentity(id) {
|
|
|
16909
16975
|
return id.kind === "root" ? id.root : `the SlayZone ${id.dev ? "dev " : ""}app of OS user "${id.user}"`;
|
|
16910
16976
|
}
|
|
16911
16977
|
function ownsFixedPort(hub, id) {
|
|
16912
|
-
if (id.kind === "root") return
|
|
16978
|
+
if (id.kind === "root") return import_node_path4.default.resolve(hub.root) === id.root;
|
|
16913
16979
|
return hub.user === null || hub.user === id.user;
|
|
16914
16980
|
}
|
|
16915
16981
|
function isOursElsewhere(hub, id) {
|
|
16916
|
-
if (id.kind === "root") return
|
|
16982
|
+
if (id.kind === "root") return import_node_path4.default.resolve(hub.root) === id.root;
|
|
16917
16983
|
return hub.supervised && hub.dev === id.dev && hub.user === id.user;
|
|
16918
16984
|
}
|
|
16919
16985
|
async function probeLocalHub(opts = {}) {
|
|
@@ -17501,7 +17567,7 @@ function canonical(p) {
|
|
|
17501
17567
|
}
|
|
17502
17568
|
}
|
|
17503
17569
|
function git(args, cwd) {
|
|
17504
|
-
const r = (0, import_child_process2.spawnSync)(
|
|
17570
|
+
const r = (0, import_child_process2.spawnSync)(gitCommand(), args, { cwd, encoding: "utf8" });
|
|
17505
17571
|
return { stdout: (r.stdout ?? "").trim(), status: r.status ?? 1 };
|
|
17506
17572
|
}
|
|
17507
17573
|
function isGitRepo(p) {
|
|
@@ -23089,8 +23155,8 @@ function tasksCommand() {
|
|
|
23089
23155
|
}
|
|
23090
23156
|
|
|
23091
23157
|
// src/commands/projects.ts
|
|
23092
|
-
var
|
|
23093
|
-
var
|
|
23158
|
+
var import_node_fs3 = __toESM(require("node:fs"), 1);
|
|
23159
|
+
var import_node_path5 = __toESM(require("node:path"), 1);
|
|
23094
23160
|
|
|
23095
23161
|
// ../../shared/workflow/src/types.ts
|
|
23096
23162
|
var WORKFLOW_CATEGORIES = [
|
|
@@ -25219,8 +25285,8 @@ function emoji() {
|
|
|
25219
25285
|
}
|
|
25220
25286
|
var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
25221
25287
|
var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
|
|
25222
|
-
var mac = (
|
|
25223
|
-
const escapedDelim = escapeRegex(
|
|
25288
|
+
var mac = (delimiter2) => {
|
|
25289
|
+
const escapedDelim = escapeRegex(delimiter2 ?? ":");
|
|
25224
25290
|
return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
|
|
25225
25291
|
};
|
|
25226
25292
|
var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
@@ -42952,6 +43018,9 @@ var computerUpgradeStatusSchema = external_exports.object({
|
|
|
42952
43018
|
updatedAt: external_exports.string().max(64)
|
|
42953
43019
|
}).strict();
|
|
42954
43020
|
|
|
43021
|
+
// ../../domains/computers/src/shared/direct-link.ts
|
|
43022
|
+
var DIRECT_RTC_MAX_SDP = 64 * 1024;
|
|
43023
|
+
|
|
42955
43024
|
// src/commands/projects.ts
|
|
42956
43025
|
var DEFAULT_PROJECT_COLOR = "#3b82f6";
|
|
42957
43026
|
function narrowProject(p) {
|
|
@@ -42969,20 +43038,20 @@ function normalizeProjectPath(input2) {
|
|
|
42969
43038
|
if (!input2) return null;
|
|
42970
43039
|
const trimmed = input2.trim();
|
|
42971
43040
|
if (!trimmed) return null;
|
|
42972
|
-
return
|
|
43041
|
+
return import_node_path5.default.resolve(trimmed);
|
|
42973
43042
|
}
|
|
42974
43043
|
function ensureProjectPath(projectPath) {
|
|
42975
43044
|
if (!projectPath) return false;
|
|
42976
|
-
const existedBefore =
|
|
43045
|
+
const existedBefore = import_node_fs3.default.existsSync(projectPath);
|
|
42977
43046
|
try {
|
|
42978
|
-
|
|
43047
|
+
import_node_fs3.default.mkdirSync(projectPath, { recursive: true });
|
|
42979
43048
|
} catch (error62) {
|
|
42980
43049
|
const message = error62 instanceof Error ? error62.message : String(error62);
|
|
42981
43050
|
console.error(`Failed to create project path "${projectPath}": ${message}`);
|
|
42982
43051
|
process.exit(1);
|
|
42983
43052
|
}
|
|
42984
43053
|
try {
|
|
42985
|
-
const stat2 =
|
|
43054
|
+
const stat2 = import_node_fs3.default.statSync(projectPath);
|
|
42986
43055
|
if (!stat2.isDirectory()) {
|
|
42987
43056
|
console.error(`Project path exists but is not a directory: ${projectPath}`);
|
|
42988
43057
|
process.exit(1);
|
|
@@ -43009,7 +43078,7 @@ async function resolveHubComputer(ref) {
|
|
|
43009
43078
|
process.exit(1);
|
|
43010
43079
|
}
|
|
43011
43080
|
function isAbsoluteAnywhere(p) {
|
|
43012
|
-
return
|
|
43081
|
+
return import_node_path5.default.posix.isAbsolute(p) || import_node_path5.default.win32.isAbsolute(p);
|
|
43013
43082
|
}
|
|
43014
43083
|
async function prepareFolder(input2, computer) {
|
|
43015
43084
|
const local = computer === null && await isCoLocatedHub();
|
|
@@ -43447,8 +43516,8 @@ function completionsCommand(root) {
|
|
|
43447
43516
|
}
|
|
43448
43517
|
|
|
43449
43518
|
// src/commands/init.ts
|
|
43450
|
-
var
|
|
43451
|
-
var
|
|
43519
|
+
var import_node_fs4 = __toESM(require("node:fs"), 1);
|
|
43520
|
+
var import_node_path6 = __toESM(require("node:path"), 1);
|
|
43452
43521
|
|
|
43453
43522
|
// ../../domains/ai-config/src/shared/provider-registry.ts
|
|
43454
43523
|
var PROVIDER_PATHS = {
|
|
@@ -45377,10 +45446,10 @@ function writeInstructionsToDisk(projectPath, providers) {
|
|
|
45377
45446
|
}
|
|
45378
45447
|
const written = [];
|
|
45379
45448
|
for (const filename of filenames) {
|
|
45380
|
-
const filePath =
|
|
45381
|
-
const existing =
|
|
45449
|
+
const filePath = import_node_path6.default.join(projectPath, filename);
|
|
45450
|
+
const existing = import_node_fs4.default.existsSync(filePath) ? import_node_fs4.default.readFileSync(filePath, "utf-8") : "";
|
|
45382
45451
|
const prefix = existing && !existing.endsWith("\n") ? "\n" : "";
|
|
45383
|
-
|
|
45452
|
+
import_node_fs4.default.appendFileSync(filePath, prefix + INSTRUCTIONS, "utf-8");
|
|
45384
45453
|
written.push(filename);
|
|
45385
45454
|
}
|
|
45386
45455
|
return written;
|
|
@@ -45390,9 +45459,9 @@ function writeSkillsToDisk(projectPath, providers, skills) {
|
|
|
45390
45459
|
const mapping = PROVIDER_PATHS[provider];
|
|
45391
45460
|
if (!mapping?.skillsDir) continue;
|
|
45392
45461
|
for (const skill of skills) {
|
|
45393
|
-
const filePath =
|
|
45394
|
-
|
|
45395
|
-
|
|
45462
|
+
const filePath = import_node_path6.default.join(projectPath, mapping.skillsDir, skill.slug, "SKILL.md");
|
|
45463
|
+
import_node_fs4.default.mkdirSync(import_node_path6.default.dirname(filePath), { recursive: true });
|
|
45464
|
+
import_node_fs4.default.writeFileSync(filePath, skill.content, "utf-8");
|
|
45396
45465
|
}
|
|
45397
45466
|
}
|
|
45398
45467
|
}
|
|
@@ -45416,8 +45485,8 @@ async function resolveTargetProject(explicit) {
|
|
|
45416
45485
|
return { ref: data.id, localFolder: data.path };
|
|
45417
45486
|
}
|
|
45418
45487
|
async function runInstall(opts) {
|
|
45419
|
-
const explicitPath = opts.path ?
|
|
45420
|
-
if (explicitPath && !
|
|
45488
|
+
const explicitPath = opts.path ? import_node_path6.default.resolve(opts.path) : null;
|
|
45489
|
+
if (explicitPath && !import_node_fs4.default.statSync(explicitPath).isDirectory()) {
|
|
45421
45490
|
throw new Error(`Not a directory: ${explicitPath}`);
|
|
45422
45491
|
}
|
|
45423
45492
|
const { ref: projectRef, localFolder } = await resolveTargetProject(opts.project);
|
|
@@ -45427,7 +45496,7 @@ async function runInstall(opts) {
|
|
|
45427
45496
|
);
|
|
45428
45497
|
const { project, providers, stats, skills } = data;
|
|
45429
45498
|
const candidate = explicitPath ?? localFolder ?? project.path;
|
|
45430
|
-
const localPath = candidate &&
|
|
45499
|
+
const localPath = candidate && import_node_fs4.default.existsSync(candidate) ? candidate : null;
|
|
45431
45500
|
if (opts.writeInstructions && localPath) {
|
|
45432
45501
|
const written = writeInstructionsToDisk(localPath, providers);
|
|
45433
45502
|
for (const f of written) console.log(` Appended instructions to ${f}`);
|
|
@@ -46402,7 +46471,7 @@ function templatesCommand() {
|
|
|
46402
46471
|
}
|
|
46403
46472
|
|
|
46404
46473
|
// src/commands/automations.ts
|
|
46405
|
-
var
|
|
46474
|
+
var import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
46406
46475
|
|
|
46407
46476
|
// ../../domains/automations/src/shared/templates.ts
|
|
46408
46477
|
var TEMPLATE_VARIABLES = [
|
|
@@ -46510,7 +46579,7 @@ function automationsCommand() {
|
|
|
46510
46579
|
let conditions = [];
|
|
46511
46580
|
let actions;
|
|
46512
46581
|
if (opts.config) {
|
|
46513
|
-
const raw =
|
|
46582
|
+
const raw = import_node_fs5.default.readFileSync(opts.config, "utf-8");
|
|
46514
46583
|
const config2 = JSON.parse(raw);
|
|
46515
46584
|
triggerConfig = config2.trigger_config;
|
|
46516
46585
|
conditions = config2.conditions ?? [];
|
|
@@ -46737,12 +46806,12 @@ function panelsCommand() {
|
|
|
46737
46806
|
|
|
46738
46807
|
// src/commands/hub.ts
|
|
46739
46808
|
var import_node_child_process5 = require("node:child_process");
|
|
46740
|
-
var
|
|
46741
|
-
var
|
|
46809
|
+
var import_node_fs11 = require("node:fs");
|
|
46810
|
+
var import_node_path11 = require("node:path");
|
|
46742
46811
|
|
|
46743
46812
|
// ../../shared/platform/src/slayzone-config.ts
|
|
46744
|
-
var
|
|
46745
|
-
var
|
|
46813
|
+
var import_node_fs6 = require("node:fs");
|
|
46814
|
+
var import_node_path7 = require("node:path");
|
|
46746
46815
|
var HUB_CONFIG_SWITCH_KEYS = [
|
|
46747
46816
|
"requireLogin",
|
|
46748
46817
|
"enablePassword",
|
|
@@ -46752,13 +46821,13 @@ var HUB_CONFIG_SWITCH_KEYS = [
|
|
|
46752
46821
|
"enableTelemetry"
|
|
46753
46822
|
];
|
|
46754
46823
|
function getHubConfigFilePath() {
|
|
46755
|
-
return (0,
|
|
46824
|
+
return (0, import_node_path7.join)(getSlayzoneHomeDir(), "hub.config.json");
|
|
46756
46825
|
}
|
|
46757
46826
|
function getComputerConfigFilePath() {
|
|
46758
|
-
return (0,
|
|
46827
|
+
return (0, import_node_path7.join)(getSlayzoneHomeDir(), "computer.config.json");
|
|
46759
46828
|
}
|
|
46760
46829
|
function legacyConfigFilePathFor(newFilePath) {
|
|
46761
|
-
return (0,
|
|
46830
|
+
return (0, import_node_path7.join)((0, import_node_path7.dirname)(newFilePath), "config.json");
|
|
46762
46831
|
}
|
|
46763
46832
|
function coerceHubConfig(raw) {
|
|
46764
46833
|
const cfg = {};
|
|
@@ -46775,6 +46844,8 @@ function coerceHubConfig(raw) {
|
|
|
46775
46844
|
cfg.ssoTenantId = raw.ssoTenantId.trim();
|
|
46776
46845
|
if (typeof raw.ssoClientId === "string" && raw.ssoClientId.trim().length > 0)
|
|
46777
46846
|
cfg.ssoClientId = raw.ssoClientId.trim();
|
|
46847
|
+
if (Array.isArray(raw.stunAddresses) && raw.stunAddresses.every((a) => typeof a === "string"))
|
|
46848
|
+
cfg.stunAddresses = raw.stunAddresses;
|
|
46778
46849
|
return cfg;
|
|
46779
46850
|
}
|
|
46780
46851
|
function coerceComputerConfig(raw) {
|
|
@@ -46793,12 +46864,14 @@ function coerceComputerConfig(raw) {
|
|
|
46793
46864
|
const roots = raw.allowedRoots.filter((r) => typeof r === "string" && r.length > 0);
|
|
46794
46865
|
if (roots.length > 0) cfg.allowedRoots = roots;
|
|
46795
46866
|
}
|
|
46867
|
+
if (typeof raw.directListenAddress === "string") cfg.directListenAddress = raw.directListenAddress;
|
|
46868
|
+
if (typeof raw.directPublicAddress === "string") cfg.directPublicAddress = raw.directPublicAddress;
|
|
46796
46869
|
return cfg;
|
|
46797
46870
|
}
|
|
46798
46871
|
function readJsonObject2(path12) {
|
|
46799
46872
|
let raw;
|
|
46800
46873
|
try {
|
|
46801
|
-
raw = (0,
|
|
46874
|
+
raw = (0, import_node_fs6.readFileSync)(path12, "utf8");
|
|
46802
46875
|
} catch (err) {
|
|
46803
46876
|
if (err.code === "ENOENT") return null;
|
|
46804
46877
|
process.stderr.write(
|
|
@@ -46825,15 +46898,15 @@ function readJsonObject2(path12) {
|
|
|
46825
46898
|
return parsed;
|
|
46826
46899
|
}
|
|
46827
46900
|
function writeJsonAtomic(path12, data) {
|
|
46828
|
-
const dir = (0,
|
|
46829
|
-
(0,
|
|
46901
|
+
const dir = (0, import_node_path7.dirname)(path12);
|
|
46902
|
+
(0, import_node_fs6.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
46830
46903
|
const tmpPath = `${path12}.tmp-${process.pid}-${Date.now()}`;
|
|
46831
|
-
(0,
|
|
46904
|
+
(0, import_node_fs6.writeFileSync)(tmpPath, `${JSON.stringify(data, null, 2)}
|
|
46832
46905
|
`, { mode: 384 });
|
|
46833
46906
|
try {
|
|
46834
|
-
(0,
|
|
46907
|
+
(0, import_node_fs6.renameSync)(tmpPath, path12);
|
|
46835
46908
|
} catch (err) {
|
|
46836
|
-
(0,
|
|
46909
|
+
(0, import_node_fs6.rmSync)(tmpPath, { force: true });
|
|
46837
46910
|
throw err;
|
|
46838
46911
|
}
|
|
46839
46912
|
}
|
|
@@ -46870,9 +46943,9 @@ function updateComputerConfigFile(patch, path12 = getComputerConfigFilePath()) {
|
|
|
46870
46943
|
|
|
46871
46944
|
// ../../shared/platform/src/service-unit.ts
|
|
46872
46945
|
var import_node_child_process2 = require("node:child_process");
|
|
46873
|
-
var
|
|
46946
|
+
var import_node_fs7 = require("node:fs");
|
|
46874
46947
|
var import_node_os2 = require("node:os");
|
|
46875
|
-
var
|
|
46948
|
+
var import_node_path8 = require("node:path");
|
|
46876
46949
|
var KINDS = {
|
|
46877
46950
|
"computer-host": {
|
|
46878
46951
|
labelPrefix: "com.slayzone.session-host.",
|
|
@@ -46917,8 +46990,8 @@ function assertValidServiceName(kind, name) {
|
|
|
46917
46990
|
}
|
|
46918
46991
|
function defaultUnitDir(backend) {
|
|
46919
46992
|
const home = process.env.HOME ?? (0, import_node_os2.homedir)();
|
|
46920
|
-
if (backend === "launchd") return (0,
|
|
46921
|
-
if (backend === "systemd") return (0,
|
|
46993
|
+
if (backend === "launchd") return (0, import_node_path8.join)(home, "Library", "LaunchAgents");
|
|
46994
|
+
if (backend === "systemd") return (0, import_node_path8.join)(home, ".config", "systemd", "user");
|
|
46922
46995
|
throw new Error("[slayzone] no unit directory: this platform has no user service backend");
|
|
46923
46996
|
}
|
|
46924
46997
|
function derivedRuntimeDir() {
|
|
@@ -46926,7 +46999,7 @@ function derivedRuntimeDir() {
|
|
|
46926
46999
|
const uid = process.getuid?.();
|
|
46927
47000
|
if (uid === void 0) return null;
|
|
46928
47001
|
const dir = `/run/user/${uid}`;
|
|
46929
|
-
return (0,
|
|
47002
|
+
return (0, import_node_fs7.existsSync)(dir) ? dir : null;
|
|
46930
47003
|
}
|
|
46931
47004
|
function userServiceEnv() {
|
|
46932
47005
|
const dir = derivedRuntimeDir();
|
|
@@ -46986,7 +47059,7 @@ then log out and back in.`;
|
|
|
46986
47059
|
}
|
|
46987
47060
|
function unitPath(kind, name, backend, unitDir = defaultUnitDir(backend)) {
|
|
46988
47061
|
assertValidServiceName(kind, name);
|
|
46989
|
-
return backend === "launchd" ? (0,
|
|
47062
|
+
return backend === "launchd" ? (0, import_node_path8.join)(unitDir, `${KINDS[kind].labelPrefix}${name}.plist`) : (0, import_node_path8.join)(unitDir, `${KINDS[kind].systemdPrefix}${name}.service`);
|
|
46990
47063
|
}
|
|
46991
47064
|
function nameFromUnitFile(kind, file2, backend) {
|
|
46992
47065
|
if (backend === "launchd") {
|
|
@@ -47048,9 +47121,9 @@ ${envEntries}
|
|
|
47048
47121
|
<false/>
|
|
47049
47122
|
</dict>
|
|
47050
47123
|
<key>StandardOutPath</key>
|
|
47051
|
-
<string>${xmlEscape((0,
|
|
47124
|
+
<string>${xmlEscape((0, import_node_path8.join)(spec.logDir, kind.outLog))}</string>
|
|
47052
47125
|
<key>StandardErrorPath</key>
|
|
47053
|
-
<string>${xmlEscape((0,
|
|
47126
|
+
<string>${xmlEscape((0, import_node_path8.join)(spec.logDir, kind.errLog))}</string>
|
|
47054
47127
|
<key>ProcessType</key>
|
|
47055
47128
|
<string>Background</string>
|
|
47056
47129
|
</dict>
|
|
@@ -47084,48 +47157,48 @@ WantedBy=default.target
|
|
|
47084
47157
|
}
|
|
47085
47158
|
function writeUnit(spec, backend, unitDir = defaultUnitDir(backend)) {
|
|
47086
47159
|
const path12 = unitPath(spec.kind, spec.name, backend, unitDir);
|
|
47087
|
-
(0,
|
|
47160
|
+
(0, import_node_fs7.mkdirSync)(unitDir, { recursive: true });
|
|
47088
47161
|
const content = backend === "launchd" ? renderLaunchdPlist(spec) : renderSystemdUnit(spec);
|
|
47089
47162
|
if (!unitHoldsSecret(spec)) {
|
|
47090
|
-
(0,
|
|
47163
|
+
(0, import_node_fs7.writeFileSync)(path12, content, { mode: 420 });
|
|
47091
47164
|
return path12;
|
|
47092
47165
|
}
|
|
47093
47166
|
const tmp = `${path12}.${process.pid}.tmp`;
|
|
47094
|
-
(0,
|
|
47167
|
+
(0, import_node_fs7.rmSync)(tmp, { force: true });
|
|
47095
47168
|
try {
|
|
47096
|
-
(0,
|
|
47097
|
-
(0,
|
|
47098
|
-
(0,
|
|
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);
|
|
47099
47172
|
} catch (err) {
|
|
47100
|
-
(0,
|
|
47173
|
+
(0, import_node_fs7.rmSync)(tmp, { force: true });
|
|
47101
47174
|
throw err;
|
|
47102
47175
|
}
|
|
47103
47176
|
return path12;
|
|
47104
47177
|
}
|
|
47105
47178
|
function removeUnit(kind, name, backend, unitDir = defaultUnitDir(backend)) {
|
|
47106
47179
|
const path12 = unitPath(kind, name, backend, unitDir);
|
|
47107
|
-
if (!(0,
|
|
47108
|
-
(0,
|
|
47180
|
+
if (!(0, import_node_fs7.existsSync)(path12)) return false;
|
|
47181
|
+
(0, import_node_fs7.rmSync)(path12, { force: true });
|
|
47109
47182
|
return true;
|
|
47110
47183
|
}
|
|
47111
47184
|
function listRegisteredUnits(kind, backend, unitDir = defaultUnitDir(backend)) {
|
|
47112
47185
|
let files;
|
|
47113
47186
|
try {
|
|
47114
|
-
files = (0,
|
|
47187
|
+
files = (0, import_node_fs7.readdirSync)(unitDir);
|
|
47115
47188
|
} catch {
|
|
47116
47189
|
return [];
|
|
47117
47190
|
}
|
|
47118
47191
|
const out = [];
|
|
47119
47192
|
for (const file2 of files) {
|
|
47120
47193
|
const name = nameFromUnitFile(kind, file2, backend);
|
|
47121
|
-
if (name) out.push({ name, unitPath: (0,
|
|
47194
|
+
if (name) out.push({ name, unitPath: (0, import_node_path8.join)(unitDir, file2) });
|
|
47122
47195
|
}
|
|
47123
47196
|
return out.sort((a, b) => a.name.localeCompare(b.name));
|
|
47124
47197
|
}
|
|
47125
47198
|
function readUnitRoot(kind, name, backend, unitDir = defaultUnitDir(backend)) {
|
|
47126
47199
|
let text;
|
|
47127
47200
|
try {
|
|
47128
|
-
text = (0,
|
|
47201
|
+
text = (0, import_node_fs7.readFileSync)(unitPath(kind, name, backend, unitDir), "utf8");
|
|
47129
47202
|
} catch {
|
|
47130
47203
|
return null;
|
|
47131
47204
|
}
|
|
@@ -47148,7 +47221,7 @@ function launchdLabel(kind, name) {
|
|
|
47148
47221
|
function readUnitEnv(kind, name, backend, unitDir = defaultUnitDir(backend)) {
|
|
47149
47222
|
let text;
|
|
47150
47223
|
try {
|
|
47151
|
-
text = (0,
|
|
47224
|
+
text = (0, import_node_fs7.readFileSync)(unitPath(kind, name, backend, unitDir), "utf8");
|
|
47152
47225
|
} catch {
|
|
47153
47226
|
return {};
|
|
47154
47227
|
}
|
|
@@ -47173,9 +47246,9 @@ function readUnitSecrets(kind, name, backend, unitDir = defaultUnitDir(backend))
|
|
|
47173
47246
|
}
|
|
47174
47247
|
|
|
47175
47248
|
// ../../shared/platform/src/computer-launcher.ts
|
|
47176
|
-
var import_node_fs7 = require("node:fs");
|
|
47177
|
-
var import_node_path8 = require("node:path");
|
|
47178
47249
|
var import_node_fs8 = require("node:fs");
|
|
47250
|
+
var import_node_path9 = require("node:path");
|
|
47251
|
+
var import_node_fs9 = require("node:fs");
|
|
47179
47252
|
var COMPUTER_LAUNCHER = String.raw`#!/usr/bin/env node
|
|
47180
47253
|
const fs = require('node:fs'), path = require('node:path'), cp = require('node:child_process');
|
|
47181
47254
|
const root = process.env.SLAYZONE_ROOT;
|
|
@@ -47216,48 +47289,48 @@ for (const signal of ['SIGINT','SIGTERM']) process.on(signal, () => {stopping =
|
|
|
47216
47289
|
launch();
|
|
47217
47290
|
`;
|
|
47218
47291
|
function ensureComputerLauncher(root, release, forceUpgrade = false) {
|
|
47219
|
-
const dir = (0,
|
|
47220
|
-
(0,
|
|
47221
|
-
const launcher = (0,
|
|
47222
|
-
(0,
|
|
47292
|
+
const dir = (0, import_node_path9.join)(root, "computer-runtime");
|
|
47293
|
+
(0, import_node_fs8.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
47294
|
+
const launcher = (0, import_node_path9.join)(dir, "launch.cjs");
|
|
47295
|
+
(0, import_node_fs8.writeFileSync)(launcher + ".tmp", COMPUTER_LAUNCHER, { mode: 448 });
|
|
47223
47296
|
renameLauncher(launcher);
|
|
47224
47297
|
if (forceUpgrade) {
|
|
47225
47298
|
for (const name of ["supervisor.json", "host-release.json"]) {
|
|
47226
|
-
const path12 = (0,
|
|
47299
|
+
const path12 = (0, import_node_path9.join)(dir, name);
|
|
47227
47300
|
let previous;
|
|
47228
47301
|
try {
|
|
47229
47302
|
previous = JSON.parse(readPointer(path12)).current;
|
|
47230
47303
|
} catch {
|
|
47231
47304
|
}
|
|
47232
|
-
(0,
|
|
47305
|
+
(0, import_node_fs8.writeFileSync)(
|
|
47233
47306
|
path12 + ".tmp",
|
|
47234
47307
|
JSON.stringify({ current: release, ...previous ? { previous } : {} }),
|
|
47235
47308
|
{ mode: 384 }
|
|
47236
47309
|
);
|
|
47237
|
-
(0,
|
|
47310
|
+
(0, import_node_fs9.renameSync)(path12 + ".tmp", path12);
|
|
47238
47311
|
}
|
|
47239
47312
|
}
|
|
47240
|
-
const hostPointer = (0,
|
|
47241
|
-
if (!(0,
|
|
47242
|
-
(0,
|
|
47243
|
-
const pointer = (0,
|
|
47244
|
-
if (!(0,
|
|
47245
|
-
(0,
|
|
47313
|
+
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" });
|
|
47316
|
+
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" });
|
|
47246
47319
|
return launcher;
|
|
47247
47320
|
}
|
|
47248
47321
|
function readPointer(path12) {
|
|
47249
|
-
return (0,
|
|
47322
|
+
return (0, import_node_fs9.readFileSync)(path12, "utf8");
|
|
47250
47323
|
}
|
|
47251
47324
|
function renameLauncher(path12) {
|
|
47252
|
-
(0,
|
|
47325
|
+
(0, import_node_fs9.renameSync)(path12 + ".tmp", path12);
|
|
47253
47326
|
}
|
|
47254
47327
|
|
|
47255
47328
|
// src/service.ts
|
|
47256
47329
|
var import_node_child_process3 = require("node:child_process");
|
|
47257
|
-
var
|
|
47330
|
+
var import_node_fs10 = require("node:fs");
|
|
47258
47331
|
var import_node_module = require("node:module");
|
|
47259
|
-
var
|
|
47260
|
-
var CLI_VERSION = true ? "0.38.
|
|
47332
|
+
var import_node_path10 = require("node:path");
|
|
47333
|
+
var CLI_VERSION = true ? "0.38.2" : "";
|
|
47261
47334
|
function fail(message) {
|
|
47262
47335
|
console.error(message);
|
|
47263
47336
|
process.exit(1);
|
|
@@ -47290,25 +47363,25 @@ function servicePackage(kind) {
|
|
|
47290
47363
|
function readServicePkg(kind, pkgJsonPath) {
|
|
47291
47364
|
let pkg;
|
|
47292
47365
|
try {
|
|
47293
|
-
pkg = JSON.parse((0,
|
|
47366
|
+
pkg = JSON.parse((0, import_node_fs10.readFileSync)(pkgJsonPath, "utf8"));
|
|
47294
47367
|
} catch {
|
|
47295
47368
|
return null;
|
|
47296
47369
|
}
|
|
47297
47370
|
const binRel = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.[PACKAGES[kind].bin];
|
|
47298
47371
|
if (!binRel) return null;
|
|
47299
|
-
const binPath = (0,
|
|
47300
|
-
if (!(0,
|
|
47372
|
+
const binPath = (0, import_node_path10.join)((0, import_node_path10.dirname)(pkgJsonPath), binRel);
|
|
47373
|
+
if (!(0, import_node_fs10.existsSync)(binPath)) return null;
|
|
47301
47374
|
return { binPath, version: pkg.version ?? "unknown" };
|
|
47302
47375
|
}
|
|
47303
47376
|
function interpreterFor(binPath, version2) {
|
|
47304
|
-
let dir = (0,
|
|
47377
|
+
let dir = (0, import_node_path10.dirname)(binPath);
|
|
47305
47378
|
for (let i = 0; i < 6; i++) {
|
|
47306
|
-
const pathTxt = (0,
|
|
47307
|
-
if ((0,
|
|
47379
|
+
const pathTxt = (0, import_node_path10.join)(dir, "node_modules", "electron", "path.txt");
|
|
47380
|
+
if ((0, import_node_fs10.existsSync)(pathTxt)) {
|
|
47308
47381
|
try {
|
|
47309
|
-
const rel = (0,
|
|
47310
|
-
const electron = (0,
|
|
47311
|
-
if ((0,
|
|
47382
|
+
const rel = (0, import_node_fs10.readFileSync)(pathTxt, "utf8").trim();
|
|
47383
|
+
const electron = (0, import_node_path10.join)(dir, "node_modules", "electron", "dist", rel);
|
|
47384
|
+
if ((0, import_node_fs10.existsSync)(electron)) {
|
|
47312
47385
|
return {
|
|
47313
47386
|
command: electron,
|
|
47314
47387
|
args: [binPath],
|
|
@@ -47320,7 +47393,7 @@ function interpreterFor(binPath, version2) {
|
|
|
47320
47393
|
} catch {
|
|
47321
47394
|
}
|
|
47322
47395
|
}
|
|
47323
|
-
const parent = (0,
|
|
47396
|
+
const parent = (0, import_node_path10.dirname)(dir);
|
|
47324
47397
|
if (parent === dir) break;
|
|
47325
47398
|
dir = parent;
|
|
47326
47399
|
}
|
|
@@ -47348,7 +47421,7 @@ function resolveServiceBin(kind, computerRoot, forceUpgrade = false) {
|
|
|
47348
47421
|
// this package's CJS bundle.
|
|
47349
47422
|
() => {
|
|
47350
47423
|
try {
|
|
47351
|
-
return (0, import_node_module.createRequire)(process.argv[1] ?? (0,
|
|
47424
|
+
return (0, import_node_module.createRequire)(process.argv[1] ?? (0, import_node_path10.join)(process.cwd(), "x")).resolve(
|
|
47352
47425
|
`${pkg}/package.json`
|
|
47353
47426
|
);
|
|
47354
47427
|
} catch {
|
|
@@ -47359,8 +47432,8 @@ function resolveServiceBin(kind, computerRoot, forceUpgrade = false) {
|
|
|
47359
47432
|
() => {
|
|
47360
47433
|
const self2 = process.argv[1];
|
|
47361
47434
|
if (!self2) return null;
|
|
47362
|
-
const sibling = (0,
|
|
47363
|
-
return (0,
|
|
47435
|
+
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;
|
|
47364
47437
|
}
|
|
47365
47438
|
];
|
|
47366
47439
|
for (const find of candidates) {
|
|
@@ -47370,11 +47443,11 @@ function resolveServiceBin(kind, computerRoot, forceUpgrade = false) {
|
|
|
47370
47443
|
if (found3) return resolve2(interpreterFor(found3.binPath, found3.version));
|
|
47371
47444
|
}
|
|
47372
47445
|
const prefix = getServiceRuntimeDir(kind);
|
|
47373
|
-
const installed = (0,
|
|
47446
|
+
const installed = (0, import_node_path10.join)(prefix, "node_modules", pkg, "package.json");
|
|
47374
47447
|
const wanted = CLI_VERSION ? `${pkg}@${CLI_VERSION}` : `${pkg}@beta`;
|
|
47375
|
-
if (!(0,
|
|
47448
|
+
if (!(0, import_node_fs10.existsSync)(installed) || CLI_VERSION && readServicePkg(kind, installed)?.version !== CLI_VERSION) {
|
|
47376
47449
|
console.log(`Installing ${wanted}\u2026`);
|
|
47377
|
-
(0,
|
|
47450
|
+
(0, import_node_fs10.mkdirSync)(prefix, { recursive: true });
|
|
47378
47451
|
try {
|
|
47379
47452
|
(0, import_node_child_process3.execFileSync)(
|
|
47380
47453
|
"npm",
|
|
@@ -47399,21 +47472,21 @@ function resolveServiceBin(kind, computerRoot, forceUpgrade = false) {
|
|
|
47399
47472
|
}
|
|
47400
47473
|
function ensureLogDir(kind, root) {
|
|
47401
47474
|
const dir = logDirFor(kind, root);
|
|
47402
|
-
(0,
|
|
47475
|
+
(0, import_node_fs10.mkdirSync)(dir, { recursive: true });
|
|
47403
47476
|
return dir;
|
|
47404
47477
|
}
|
|
47405
47478
|
function logDirFor(_kind, root) {
|
|
47406
|
-
return (0,
|
|
47479
|
+
return (0, import_node_path10.join)(root, "logs");
|
|
47407
47480
|
}
|
|
47408
47481
|
function serviceLogPaths(kind, root) {
|
|
47409
47482
|
const dir = logDirFor(kind, root);
|
|
47410
47483
|
const names = serviceLogNames(kind);
|
|
47411
|
-
return { out: (0,
|
|
47484
|
+
return { out: (0, import_node_path10.join)(dir, names.out), err: (0, import_node_path10.join)(dir, names.err) };
|
|
47412
47485
|
}
|
|
47413
47486
|
function failWithLog(kind, name, logPath, what) {
|
|
47414
47487
|
let detail = "";
|
|
47415
47488
|
try {
|
|
47416
|
-
detail = (0,
|
|
47489
|
+
detail = (0, import_node_fs10.readFileSync)(logPath, "utf8").trim().split("\n").slice(-12).join("\n");
|
|
47417
47490
|
} catch {
|
|
47418
47491
|
}
|
|
47419
47492
|
const label = kind === "hub" ? "Hub" : "Computer";
|
|
@@ -47442,14 +47515,14 @@ function readServiceLogTail(kind, root, lines, systemdUnit) {
|
|
|
47442
47515
|
const dir = logDirFor(kind, root);
|
|
47443
47516
|
let files;
|
|
47444
47517
|
try {
|
|
47445
|
-
files = (0,
|
|
47518
|
+
files = (0, import_node_fs10.readdirSync)(dir).filter((f) => f.endsWith(".log"));
|
|
47446
47519
|
} catch {
|
|
47447
47520
|
return "";
|
|
47448
47521
|
}
|
|
47449
47522
|
const chunks = [];
|
|
47450
47523
|
for (const f of files) {
|
|
47451
47524
|
try {
|
|
47452
|
-
chunks.push((0,
|
|
47525
|
+
chunks.push((0, import_node_fs10.readFileSync)((0, import_node_path10.join)(dir, f), "utf8"));
|
|
47453
47526
|
} catch {
|
|
47454
47527
|
}
|
|
47455
47528
|
}
|
|
@@ -47465,8 +47538,8 @@ function followServiceLog(args) {
|
|
|
47465
47538
|
return;
|
|
47466
47539
|
}
|
|
47467
47540
|
const dir = logDirFor(kind, root);
|
|
47468
|
-
if (!(0,
|
|
47469
|
-
const candidates = (0,
|
|
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);
|
|
47470
47543
|
if (candidates.length === 0) fail(`No log files in ${shortenPath(dir)}.`);
|
|
47471
47544
|
const target = candidates[0].path;
|
|
47472
47545
|
const targs = follow ? ["-f", "-n", String(lines), target] : ["-n", String(lines), target];
|
|
@@ -47714,25 +47787,13 @@ function postJson2(transport, url2, body, timeoutMs) {
|
|
|
47714
47787
|
}
|
|
47715
47788
|
|
|
47716
47789
|
// ../../domains/hub-auth/src/client/sign-in-error.ts
|
|
47717
|
-
var
|
|
47718
|
-
var MESSAGES2 = {
|
|
47719
|
-
// T-09 refuses every ID token that fails its checks with this generic code: another
|
|
47720
|
-
// tenant, no MFA, no SlayZone app role, no email (the audit line names which).
|
|
47721
|
-
unable_to_get_user_info: "Microsoft refused this account for this hub: it may belong to another organisation, have signed in without multi-factor authentication, or not be assigned to SlayZone. Ask your administrator.",
|
|
47722
|
-
ACCOUNT_DISABLED: "This account is disabled on this hub. Ask your administrator.",
|
|
47723
|
-
account_not_linked: "The email of this Microsoft account already belongs to another account on this hub, so it cannot sign in. Ask your administrator.",
|
|
47724
|
-
unable_to_link_account: "This Microsoft account could not be connected to an account on this hub. Ask your administrator.",
|
|
47725
|
-
access_denied: "Sign-in was cancelled at Microsoft. Try again.",
|
|
47726
|
-
state_mismatch: "The sign-in took too long or was started in another tab. Try again.",
|
|
47727
|
-
please_restart_the_process: "The sign-in took too long or was started in another tab. Try again.",
|
|
47728
|
-
invalid_callback_request: "The sign-in took too long or was started in another tab. Try again.",
|
|
47729
|
-
no_session: `Microsoft sign-in did not complete. Try again. ${ASK_ADMIN}`,
|
|
47730
|
-
// App sign-in (`src/server/app-sign-in.ts`).
|
|
47731
|
-
flow_expired: "The sign-in took too long or its browser window was closed. Try again.",
|
|
47732
|
-
temporarily_unavailable: "Too many sign-ins are waiting on this hub. Try again in a few minutes."
|
|
47733
|
-
};
|
|
47790
|
+
var DEFAULT_SSO_LABEL = "Microsoft";
|
|
47734
47791
|
|
|
47735
47792
|
// ../../domains/hub-auth/src/client/health.ts
|
|
47793
|
+
function ssoLabelOf(health) {
|
|
47794
|
+
const label = health?.ssoLabel;
|
|
47795
|
+
return typeof label === "string" && /^[\p{L}\p{N} ._-]{1,32}$/u.test(label) ? label : DEFAULT_SSO_LABEL;
|
|
47796
|
+
}
|
|
47736
47797
|
async function fetchHubHealth(transport, baseUrl, timeoutMs) {
|
|
47737
47798
|
try {
|
|
47738
47799
|
const res = await transport({
|
|
@@ -47756,7 +47817,11 @@ function signInMethodsOf(health) {
|
|
|
47756
47817
|
const switches = health.switches;
|
|
47757
47818
|
if (!switches) return void 0;
|
|
47758
47819
|
const sw = switches;
|
|
47759
|
-
return {
|
|
47820
|
+
return {
|
|
47821
|
+
sso: sw.enableSso === true,
|
|
47822
|
+
password: sw.enablePassword !== false,
|
|
47823
|
+
ssoLabel: ssoLabelOf(health)
|
|
47824
|
+
};
|
|
47760
47825
|
}
|
|
47761
47826
|
|
|
47762
47827
|
// ../../domains/hub-auth/src/client/password.ts
|
|
@@ -48351,7 +48416,7 @@ async function launchHub(args) {
|
|
|
48351
48416
|
const probePort = address !== void 0 ? parseHubAddress(address)?.port : port;
|
|
48352
48417
|
const findIt = () => probePort === void 0 ? findAnyHub(name) : findHub(String(probePort));
|
|
48353
48418
|
if (backend === "none") {
|
|
48354
|
-
const out = (0,
|
|
48419
|
+
const out = (0, import_node_fs11.openSync)(logs.out, "a");
|
|
48355
48420
|
const child = (0, import_node_child_process5.spawn)(bin.command, bin.args, {
|
|
48356
48421
|
cwd: root,
|
|
48357
48422
|
detached: true,
|
|
@@ -48458,7 +48523,7 @@ then log out and back in, and retry. If this account is not meant to have one (a
|
|
|
48458
48523
|
}
|
|
48459
48524
|
}
|
|
48460
48525
|
async function haltHub(hub, backend, opts) {
|
|
48461
|
-
if (backend !== "none" && (0,
|
|
48526
|
+
if (backend !== "none" && (0, import_node_fs11.existsSync)(unitPath("hub", hub.name, backend))) {
|
|
48462
48527
|
supervisorStop("hub", backend, hub.name);
|
|
48463
48528
|
if (opts.unregister) removeUnit("hub", hub.name, backend);
|
|
48464
48529
|
} else {
|
|
@@ -48629,10 +48694,10 @@ function hubCommand() {
|
|
|
48629
48694
|
console.log(
|
|
48630
48695
|
`${"-".repeat(nameW)} ${"-".repeat(5)} ${"-".repeat(7)} ${"-".repeat(rootW)} ${"-".repeat(9)} ${"-".repeat(8)}`
|
|
48631
48696
|
);
|
|
48632
|
-
const ownRoot = process.env.SLAYZONE_ROOT?.trim() ? (0,
|
|
48697
|
+
const ownRoot = process.env.SLAYZONE_ROOT?.trim() ? (0, import_node_path11.resolve)(process.env.SLAYZONE_ROOT.trim()) : null;
|
|
48633
48698
|
for (const h of hubs) {
|
|
48634
48699
|
const root = h.supervised ? "(desktop app)" : shortenPath(h.root);
|
|
48635
|
-
const mine = ownRoot && (0,
|
|
48700
|
+
const mine = ownRoot && (0, import_node_path11.resolve)(h.root) === ownRoot ? " \u2190 this shell" : "";
|
|
48636
48701
|
console.log(
|
|
48637
48702
|
`${h.name.padEnd(nameW)} ${String(h.port).padEnd(5)} ${String(h.pid).padEnd(7)} ${root.padEnd(rootW)} ${String(h.computersConnected).padEnd(9)} ${formatUptime(h.uptimeMs)}${mine}`
|
|
48638
48703
|
);
|
|
@@ -48649,7 +48714,7 @@ Task hub: ${taskHub.url} (${taskHub.connection}; connection not checked)`);
|
|
|
48649
48714
|
"Address to listen on (default: loopback). Required with --public-address: the hub serves plain http, so say whether it listens on loopback behind a same-box TLS front end (127.0.0.1) or on an interface the front end reaches (e.g. 10.0.0.4)."
|
|
48650
48715
|
).action(
|
|
48651
48716
|
async (name, opts) => {
|
|
48652
|
-
const root = (0,
|
|
48717
|
+
const root = (0, import_node_path11.resolve)(opts.root ?? process.cwd());
|
|
48653
48718
|
const port = opts.port === void 0 ? void 0 : Number(opts.port);
|
|
48654
48719
|
if (port !== void 0 && (!Number.isInteger(port) || port < 1 || port > 65535)) {
|
|
48655
48720
|
fail(`Invalid --port ${opts.port} \u2014 expected an integer 1-65535.`);
|
|
@@ -48698,14 +48763,14 @@ Avoid 0.0.0.0 unless the machine's firewall only lets the front end in.`
|
|
|
48698
48763
|
if (publicAddress !== void 0 && !authSecret) {
|
|
48699
48764
|
fail(
|
|
48700
48765
|
`A hub other machines can reach needs SLAYZONE_HUB_AUTH_SECRET in its environment \u2014 it never generates its signing key onto its own disk, and it would refuse to boot without one.
|
|
48701
|
-
Existing hub root (it already has sessions and enrolled computers): reuse its computerTransportSecret from ${(0,
|
|
48766
|
+
Existing hub root (it already has sessions and enrolled computers): reuse its computerTransportSecret from ${(0, import_node_path11.join)(root, "hub.state.json")} \u2014 a new value invalidates every session and computer credential.
|
|
48702
48767
|
New hub: generate one for this command:
|
|
48703
48768
|
SLAYZONE_HUB_AUTH_SECRET=$(openssl rand -hex 32) slay hub create ${name} --public-address ${publicAddress} --bind <host[:port]>
|
|
48704
48769
|
It is written into the hub's service unit (owner-only, 0600) so the hub keeps it across restarts.`
|
|
48705
48770
|
);
|
|
48706
48771
|
}
|
|
48707
48772
|
const backend = resolveBackend();
|
|
48708
|
-
if (backend !== "none" && (0,
|
|
48773
|
+
if (backend !== "none" && (0, import_node_fs11.existsSync)(unitPath("hub", name, backend))) {
|
|
48709
48774
|
const existingRoot = readUnitRoot("hub", name, backend);
|
|
48710
48775
|
fail(
|
|
48711
48776
|
`A hub named "${name}" already exists${existingRoot ? ` (root ${shortenPath(existingRoot)})` : ""}.
|
|
@@ -48733,7 +48798,7 @@ Start it with \`slay hub start ${name}\`, or remove it with \`slay hub rm ${name
|
|
|
48733
48798
|
publicAddress,
|
|
48734
48799
|
...address !== void 0 ? { listenAddress: address } : {}
|
|
48735
48800
|
},
|
|
48736
|
-
(0,
|
|
48801
|
+
(0, import_node_path11.join)(root, "hub.config.json")
|
|
48737
48802
|
);
|
|
48738
48803
|
console.log("Reachable: login required (SLAYZONE_HUB_REQUIRE_LOGIN=1)");
|
|
48739
48804
|
console.log(`Listen: ${address ?? "(hub block default)"}`);
|
|
@@ -48790,7 +48855,7 @@ machines dial, recreate it with \`--public-address <host:port>\`.`
|
|
|
48790
48855
|
`This platform has no user service manager, so hubs are not registered and \`start\` has nothing to act on. Use \`slay hub create ${name}\`.`
|
|
48791
48856
|
);
|
|
48792
48857
|
}
|
|
48793
|
-
if (!(0,
|
|
48858
|
+
if (!(0, import_node_fs11.existsSync)(unitPath("hub", name, backend))) {
|
|
48794
48859
|
fail(
|
|
48795
48860
|
`No hub named "${name}". Create it with \`slay hub create ${name}\`, or list what exists with \`slay hub registered\`.`
|
|
48796
48861
|
);
|
|
@@ -48813,7 +48878,7 @@ machines dial, recreate it with \`--public-address <host:port>\`.`
|
|
|
48813
48878
|
const hub = await requireHub(nameOrPort);
|
|
48814
48879
|
refuseSupervised(hub, "stop");
|
|
48815
48880
|
const backend = resolveBackend();
|
|
48816
|
-
const registered = backend !== "none" && (0,
|
|
48881
|
+
const registered = backend !== "none" && (0, import_node_fs11.existsSync)(unitPath("hub", hub.name, backend));
|
|
48817
48882
|
await haltHub(hub, backend, { unregister: false });
|
|
48818
48883
|
console.log(
|
|
48819
48884
|
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.`
|
|
@@ -48823,7 +48888,7 @@ machines dial, recreate it with \`--public-address <host:port>\`.`
|
|
|
48823
48888
|
const backend = resolveBackend();
|
|
48824
48889
|
const hub = await findAnyHub(nameOrPort);
|
|
48825
48890
|
if (!hub) {
|
|
48826
|
-
if (backend !== "none" && (0,
|
|
48891
|
+
if (backend !== "none" && (0, import_node_fs11.existsSync)(unitPath("hub", nameOrPort, backend))) {
|
|
48827
48892
|
const root = readUnitRoot("hub", nameOrPort, backend);
|
|
48828
48893
|
supervisorStopQuiet("hub", backend, nameOrPort);
|
|
48829
48894
|
removeUnit("hub", nameOrPort, backend);
|
|
@@ -48843,7 +48908,7 @@ machines dial, recreate it with \`--public-address <host:port>\`.`
|
|
|
48843
48908
|
const hub = await requireHub(nameOrPort);
|
|
48844
48909
|
refuseSupervised(hub, "restart");
|
|
48845
48910
|
const backend = resolveBackend();
|
|
48846
|
-
if (backend === "none" || !(0,
|
|
48911
|
+
if (backend === "none" || !(0, import_node_fs11.existsSync)(unitPath("hub", hub.name, backend))) {
|
|
48847
48912
|
fail(
|
|
48848
48913
|
`"${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}\`.`
|
|
48849
48914
|
);
|
|
@@ -48895,7 +48960,7 @@ then \`slay hub start ${name}\`.`
|
|
|
48895
48960
|
root: hub.root,
|
|
48896
48961
|
lines,
|
|
48897
48962
|
follow: opts.follow === true,
|
|
48898
|
-
systemdUnit: backend === "systemd" && (0,
|
|
48963
|
+
systemdUnit: backend === "systemd" && (0, import_node_fs11.existsSync)(unitPath("hub", hub.name, backend))
|
|
48899
48964
|
});
|
|
48900
48965
|
});
|
|
48901
48966
|
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) => {
|
|
@@ -48909,8 +48974,8 @@ then \`slay hub start ${name}\`.`
|
|
|
48909
48974
|
});
|
|
48910
48975
|
cmd.command("login <url>").description("Sign in to a hub and store its bearer token for this CLI").option(
|
|
48911
48976
|
"--email <email>",
|
|
48912
|
-
"Sign in with this account and a password (see `slay hub users ls`). Omit on a hub with
|
|
48913
|
-
).option("--password <password>", "Account password (omit to read from stdin)").option("--no-browser", "
|
|
48977
|
+
"Sign in with this account and a password (see `slay hub users ls`). Omit on a hub with SSO sign-in (Microsoft or another provider): you approve in a browser instead"
|
|
48978
|
+
).option("--password <password>", "Account password (omit to read from stdin)").option("--no-browser", "SSO sign-in: print the page, do not try to open a browser").action(
|
|
48914
48979
|
async (rawUrl, opts) => {
|
|
48915
48980
|
const url2 = normalizeHubUrl(rawUrl);
|
|
48916
48981
|
if (!url2) fail(`Invalid hub URL (expected an http(s) URL): ${rawUrl}`);
|
|
@@ -48925,11 +48990,11 @@ then \`slay hub start ${name}\`.`
|
|
|
48925
48990
|
);
|
|
48926
48991
|
}
|
|
48927
48992
|
token = await deviceSignIn(url2, { openBrowser: opts.browser });
|
|
48928
|
-
who = await signedInEmail(url2, token) ??
|
|
48993
|
+
who = await signedInEmail(url2, token) ?? `your ${methods.ssoLabel ?? DEFAULT_SSO_LABEL} account`;
|
|
48929
48994
|
} else {
|
|
48930
48995
|
if (!methods.password) {
|
|
48931
48996
|
fail(
|
|
48932
|
-
`Password sign-in is off on ${url2}. Sign in through
|
|
48997
|
+
`Password sign-in is off on ${url2}. Sign in through ${methods.ssoLabel ?? DEFAULT_SSO_LABEL} instead:
|
|
48933
48998
|
slay hub login ${rawUrl}`
|
|
48934
48999
|
);
|
|
48935
49000
|
}
|
|
@@ -49025,8 +49090,8 @@ ${target.token ?? ""}`;
|
|
|
49025
49090
|
|
|
49026
49091
|
// src/commands/computer.ts
|
|
49027
49092
|
var import_node_child_process6 = require("node:child_process");
|
|
49028
|
-
var
|
|
49029
|
-
var
|
|
49093
|
+
var import_node_fs13 = require("node:fs");
|
|
49094
|
+
var import_node_path13 = require("node:path");
|
|
49030
49095
|
|
|
49031
49096
|
// ../../shared/platform/src/join-token.ts
|
|
49032
49097
|
var JOIN_TOKEN_PREFIX = "szjt1";
|
|
@@ -49053,17 +49118,17 @@ function decodeJoinToken(token) {
|
|
|
49053
49118
|
}
|
|
49054
49119
|
|
|
49055
49120
|
// src/commands/computer-identity.ts
|
|
49056
|
-
var
|
|
49057
|
-
var
|
|
49121
|
+
var import_node_fs12 = require("node:fs");
|
|
49122
|
+
var import_node_path12 = require("node:path");
|
|
49058
49123
|
function configPathFor(root) {
|
|
49059
|
-
return (0,
|
|
49124
|
+
return (0, import_node_path12.join)(root, "computer.config.json");
|
|
49060
49125
|
}
|
|
49061
49126
|
function ambientRoot() {
|
|
49062
49127
|
return process.env.SLAYZONE_ROOT ?? process.cwd();
|
|
49063
49128
|
}
|
|
49064
49129
|
function isEnrolled(root) {
|
|
49065
49130
|
try {
|
|
49066
|
-
const parsed = JSON.parse((0,
|
|
49131
|
+
const parsed = JSON.parse((0, import_node_fs12.readFileSync)((0, import_node_path12.join)(root, "computer.state.json"), "utf8"));
|
|
49067
49132
|
return typeof parsed === "object" && parsed !== null && Object.keys(parsed).length > 0;
|
|
49068
49133
|
} catch {
|
|
49069
49134
|
return false;
|
|
@@ -49114,7 +49179,7 @@ function rootClaims(root, name) {
|
|
|
49114
49179
|
}
|
|
49115
49180
|
async function resolveComputer(name, backend, opts = {}) {
|
|
49116
49181
|
const cwd = opts.cwd ?? ambientRoot();
|
|
49117
|
-
const supervised = backend !== "none" && (0,
|
|
49182
|
+
const supervised = backend !== "none" && (0, import_node_fs12.existsSync)(unitPath("computer", name, backend));
|
|
49118
49183
|
const root = supervised ? readUnitRoot("computer", name, backend) : rootClaims(cwd, name) ? cwd : null;
|
|
49119
49184
|
const local = localFacts(name, root, backend, supervised);
|
|
49120
49185
|
if (opts.hub === false) return { ...local, connected: null };
|
|
@@ -49141,7 +49206,7 @@ async function listComputers(backend, opts = {}) {
|
|
|
49141
49206
|
for (const r of rows ?? []) names.add(r.name);
|
|
49142
49207
|
const computers = [];
|
|
49143
49208
|
for (const name of [...names].sort((a, b) => a.localeCompare(b))) {
|
|
49144
|
-
const supervised = backend !== "none" && (0,
|
|
49209
|
+
const supervised = backend !== "none" && (0, import_node_fs12.existsSync)(unitPath("computer", name, backend));
|
|
49145
49210
|
const root = supervised ? readUnitRoot("computer", name, backend) : rootClaims(cwd, name) ? cwd : null;
|
|
49146
49211
|
const local = localFacts(name, root, backend, supervised);
|
|
49147
49212
|
const row = rows?.find((r) => r.name === name) ?? null;
|
|
@@ -49214,7 +49279,7 @@ function requireRegistered(name, backend) {
|
|
|
49214
49279
|
npx ${COMPUTER_PACKAGE}`
|
|
49215
49280
|
);
|
|
49216
49281
|
}
|
|
49217
|
-
if (!(0,
|
|
49282
|
+
if (!(0, import_node_fs13.existsSync)(unitPath("computer", name, backend))) {
|
|
49218
49283
|
const known = listRegisteredUnits("computer", backend).map((u) => u.name);
|
|
49219
49284
|
fail(
|
|
49220
49285
|
`No computer named "${name}" on this machine.
|
|
@@ -49244,7 +49309,7 @@ async function launchComputer(args) {
|
|
|
49244
49309
|
const logDir = ensureLogDir("computer", root);
|
|
49245
49310
|
const logs = serviceLogPaths("computer", root);
|
|
49246
49311
|
if (backend === "none") {
|
|
49247
|
-
const out = (0,
|
|
49312
|
+
const out = (0, import_node_fs13.openSync)(logs.out, "a");
|
|
49248
49313
|
const child = (0, import_node_child_process6.spawn)(bin.command, bin.args, {
|
|
49249
49314
|
cwd: root,
|
|
49250
49315
|
detached: true,
|
|
@@ -49294,8 +49359,8 @@ async function launchComputer(args) {
|
|
|
49294
49359
|
},
|
|
49295
49360
|
backend
|
|
49296
49361
|
);
|
|
49297
|
-
(0,
|
|
49298
|
-
(0,
|
|
49362
|
+
(0, import_node_fs13.writeFileSync)(
|
|
49363
|
+
(0, import_node_path13.join)(root, "computer-runtime", "host-service.json"),
|
|
49299
49364
|
JSON.stringify({ backend, name }),
|
|
49300
49365
|
{ mode: 384 }
|
|
49301
49366
|
);
|
|
@@ -49487,7 +49552,7 @@ ${unmanaged.map((r) => `"${r.name}"`).join(", ")} ${unmanaged.length === 1 ? "is
|
|
|
49487
49552
|
"Filesystem root the computer may operate under (repeatable; default: the computer root)",
|
|
49488
49553
|
(value, previous = []) => [...previous, value]
|
|
49489
49554
|
).action(async (name, opts) => {
|
|
49490
|
-
const root = (0,
|
|
49555
|
+
const root = (0, import_node_path13.resolve)(opts.root ?? process.cwd());
|
|
49491
49556
|
const backend = resolveBackend();
|
|
49492
49557
|
const decoded = decodeJoinToken(opts.token);
|
|
49493
49558
|
if (!decoded) {
|
|
@@ -49503,7 +49568,7 @@ Mint one on the hub:
|
|
|
49503
49568
|
`"${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.`
|
|
49504
49569
|
);
|
|
49505
49570
|
}
|
|
49506
|
-
if (backend !== "none" && (0,
|
|
49571
|
+
if (backend !== "none" && (0, import_node_fs13.existsSync)(unitPath("computer", name, backend))) {
|
|
49507
49572
|
const existingRoot = readUnitRoot("computer", name, backend);
|
|
49508
49573
|
fail(
|
|
49509
49574
|
`A computer named "${name}" already exists${existingRoot ? ` (root ${shortenPath(existingRoot)})` : ""}.
|
|
@@ -49532,7 +49597,7 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
|
|
|
49532
49597
|
` If you started it in the foreground, stop that process first \u2014 otherwise two computers would share this root.`
|
|
49533
49598
|
);
|
|
49534
49599
|
}
|
|
49535
|
-
const allowedRoots = opts.allow && opts.allow.length > 0 ? opts.allow.map((d) => (0,
|
|
49600
|
+
const allowedRoots = opts.allow && opts.allow.length > 0 ? opts.allow.map((d) => (0, import_node_path13.resolve)(d)) : [root];
|
|
49536
49601
|
updateComputerConfigFile(
|
|
49537
49602
|
{
|
|
49538
49603
|
joinToken: opts.token,
|
|
@@ -49544,7 +49609,7 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
|
|
|
49544
49609
|
);
|
|
49545
49610
|
if (!adopting) {
|
|
49546
49611
|
registerCreateRollback(() => {
|
|
49547
|
-
(0,
|
|
49612
|
+
(0, import_node_fs13.rmSync)(configPathFor(root), { force: true });
|
|
49548
49613
|
});
|
|
49549
49614
|
}
|
|
49550
49615
|
console.log(`Hub: ${decoded.hubUrl}`);
|
|
@@ -49604,7 +49669,7 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
|
|
|
49604
49669
|
}
|
|
49605
49670
|
if (facts.root && facts.installed) {
|
|
49606
49671
|
if (opts.purge) {
|
|
49607
|
-
(0,
|
|
49672
|
+
(0, import_node_fs13.rmSync)(facts.root, { recursive: true, force: true });
|
|
49608
49673
|
console.log(`Deleted ${shortenPath(facts.root)}.`);
|
|
49609
49674
|
} else {
|
|
49610
49675
|
console.log(`Config and credentials remain in ${shortenPath(facts.root)}.`);
|
|
@@ -49643,7 +49708,7 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
|
|
|
49643
49708
|
supervisorStop("computer", backend, name);
|
|
49644
49709
|
supervisorStopQuiet("computer-host", backend, name);
|
|
49645
49710
|
await waitForStopped(name, backend, 15e3);
|
|
49646
|
-
if ((0,
|
|
49711
|
+
if ((0, import_node_fs13.existsSync)(unitPath("computer-host", name, backend)))
|
|
49647
49712
|
supervisorStart("computer-host", backend, name, unitPath("computer-host", name, backend));
|
|
49648
49713
|
supervisorStart("computer", backend, name, unitPath("computer", name, backend));
|
|
49649
49714
|
if (!await waitForConnected(root, ENROLL_TIMEOUT_MS, backend, name)) {
|
|
@@ -49675,9 +49740,9 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
|
|
|
49675
49740
|
return;
|
|
49676
49741
|
}
|
|
49677
49742
|
const edit = editAllowedRoots(current, {
|
|
49678
|
-
add: (opts.add ?? []).map((d) => (0,
|
|
49679
|
-
remove: (opts.remove ?? []).map((d) => (0,
|
|
49680
|
-
exists:
|
|
49743
|
+
add: (opts.add ?? []).map((d) => (0, import_node_path13.resolve)(d)),
|
|
49744
|
+
remove: (opts.remove ?? []).map((d) => (0, import_node_path13.resolve)(d)),
|
|
49745
|
+
exists: import_node_fs13.existsSync
|
|
49681
49746
|
});
|
|
49682
49747
|
if (edit.missing.length > 0) {
|
|
49683
49748
|
fail(
|
|
@@ -49705,7 +49770,7 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
|
|
|
49705
49770
|
root,
|
|
49706
49771
|
lines,
|
|
49707
49772
|
follow: opts.follow === true,
|
|
49708
|
-
systemdUnit: backend === "systemd" && (0,
|
|
49773
|
+
systemdUnit: backend === "systemd" && (0, import_node_fs13.existsSync)(unitPath("computer", name, backend))
|
|
49709
49774
|
});
|
|
49710
49775
|
});
|
|
49711
49776
|
return cmd;
|
|
@@ -49713,9 +49778,9 @@ Start it with \`slay computer start ${name}\`, or remove it with \`slay computer
|
|
|
49713
49778
|
|
|
49714
49779
|
// src/commands/update.ts
|
|
49715
49780
|
var import_node_child_process7 = require("node:child_process");
|
|
49716
|
-
var
|
|
49781
|
+
var import_node_fs14 = require("node:fs");
|
|
49717
49782
|
var import_node_os3 = require("node:os");
|
|
49718
|
-
var
|
|
49783
|
+
var import_node_path14 = require("node:path");
|
|
49719
49784
|
var PACKAGE_NAMES = ["@slayzone/cli", "@slayzone/computer", "@slayzone/hub"];
|
|
49720
49785
|
var KIND_FOR_PACKAGE = {
|
|
49721
49786
|
"@slayzone/hub": "hub",
|
|
@@ -49729,9 +49794,9 @@ function runCapture(bin, args) {
|
|
|
49729
49794
|
}
|
|
49730
49795
|
}
|
|
49731
49796
|
function bunGlobalRoot() {
|
|
49732
|
-
const base = process.env.BUN_INSTALL || (0,
|
|
49733
|
-
const dir = (0,
|
|
49734
|
-
return (0,
|
|
49797
|
+
const base = process.env.BUN_INSTALL || (0, import_node_path14.join)((0, import_node_os3.homedir)(), ".bun");
|
|
49798
|
+
const dir = (0, import_node_path14.join)(base, "install", "global", "node_modules");
|
|
49799
|
+
return (0, import_node_fs14.existsSync)(dir) ? dir : null;
|
|
49735
49800
|
}
|
|
49736
49801
|
var MANAGERS = [
|
|
49737
49802
|
{
|
|
@@ -49771,10 +49836,10 @@ var MANAGERS = [
|
|
|
49771
49836
|
}
|
|
49772
49837
|
];
|
|
49773
49838
|
function readInstalledVersion(globalRoot, pkg) {
|
|
49774
|
-
const pkgJsonPath = (0,
|
|
49775
|
-
if (!(0,
|
|
49839
|
+
const pkgJsonPath = (0, import_node_path14.join)(globalRoot, ...pkg.split("/"), "package.json");
|
|
49840
|
+
if (!(0, import_node_fs14.existsSync)(pkgJsonPath)) return null;
|
|
49776
49841
|
try {
|
|
49777
|
-
const parsed = JSON.parse((0,
|
|
49842
|
+
const parsed = JSON.parse((0, import_node_fs14.readFileSync)(pkgJsonPath, "utf8"));
|
|
49778
49843
|
return typeof parsed.version === "string" ? parsed.version : null;
|
|
49779
49844
|
} catch {
|
|
49780
49845
|
return null;
|
|
@@ -49890,7 +49955,7 @@ function updateCommand() {
|
|
|
49890
49955
|
}
|
|
49891
49956
|
|
|
49892
49957
|
// src/index.ts
|
|
49893
|
-
var program2 = new Command().name("slay").description("SlayZone CLI").version("0.38.
|
|
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) => {
|
|
49894
49959
|
const root = thisCommand.parent ?? thisCommand;
|
|
49895
49960
|
const opts = root.opts();
|
|
49896
49961
|
if (opts.dev) process.env.SLAYZONE_DEV = "1";
|