@slayzone/cli 0.36.2 → 0.36.4
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 +189 -75
- package/package.json +1 -1
package/dist/slay.js
CHANGED
|
@@ -16599,8 +16599,19 @@ function envTarget() {
|
|
|
16599
16599
|
function flagTarget() {
|
|
16600
16600
|
return hubOverride ? { ...hubOverride, source: "flag" } : null;
|
|
16601
16601
|
}
|
|
16602
|
+
function relayTarget() {
|
|
16603
|
+
if (!isTaskTerminal()) return null;
|
|
16604
|
+
const address = process.env.SLAYZONE_CLI_RELAY_ADDRESS;
|
|
16605
|
+
const token = process.env.SLAYZONE_CLI_RELAY_TOKEN;
|
|
16606
|
+
if (!address && !token) return null;
|
|
16607
|
+
if (!address || !/^127\.0\.0\.1:\d+$/.test(address) || !isBareAuthority(address) || !token) {
|
|
16608
|
+
console.error("Invalid task CLI relay configuration. Open a new task terminal.");
|
|
16609
|
+
process.exit(1);
|
|
16610
|
+
}
|
|
16611
|
+
return { baseUrl: `http://${address}`, token, source: "relay", hubUrl: envTarget()?.baseUrl };
|
|
16612
|
+
}
|
|
16602
16613
|
function resolveTaskCommandTarget() {
|
|
16603
|
-
return flagTarget() ?? envTarget() ?? (isTaskTerminal() ? null : storedTarget(true));
|
|
16614
|
+
return flagTarget() ?? relayTarget() ?? envTarget() ?? (isTaskTerminal() ? null : storedTarget(true));
|
|
16604
16615
|
}
|
|
16605
16616
|
function resolveHubCommandTarget() {
|
|
16606
16617
|
const flag = flagTarget();
|
|
@@ -16696,7 +16707,8 @@ async function isCoLocatedHub() {
|
|
|
16696
16707
|
// src/api.ts
|
|
16697
16708
|
async function resolveTarget() {
|
|
16698
16709
|
const hub = resolveTaskCommandTarget();
|
|
16699
|
-
if (hub)
|
|
16710
|
+
if (hub)
|
|
16711
|
+
return { baseUrl: hub.baseUrl, token: hub.token, hub: true, relay: hub.source === "relay" };
|
|
16700
16712
|
if (isTaskTerminal() && !process.env.SLAYZONE_ROOT?.trim()) {
|
|
16701
16713
|
console.error(
|
|
16702
16714
|
"This is a task terminal (SLAYZONE_TASK_ID is set), but it does not say which app\nspawned it: neither SLAYZONE_HUB_ADDRESS nor SLAYZONE_ROOT is set. Refusing to guess.\nOpen a new terminal from the app, or name the hub with `slay --hub <name|port>`."
|
|
@@ -16728,7 +16740,11 @@ function withAuth(init, token) {
|
|
|
16728
16740
|
return { ...init, headers };
|
|
16729
16741
|
}
|
|
16730
16742
|
function connectError(target) {
|
|
16731
|
-
if (target.
|
|
16743
|
+
if (target.relay) {
|
|
16744
|
+
console.error(
|
|
16745
|
+
"Task CLI relay is unavailable. Check the computer connection and open a new task terminal."
|
|
16746
|
+
);
|
|
16747
|
+
} else if (target.hub) {
|
|
16732
16748
|
console.error(`Could not connect to SlayZone hub at ${target.baseUrl}.`);
|
|
16733
16749
|
} else {
|
|
16734
16750
|
console.error("SlayZone is not running (could not connect to app).");
|
|
@@ -21907,7 +21923,6 @@ var import_node_stream = require("node:stream");
|
|
|
21907
21923
|
var import_promises2 = require("node:stream/promises");
|
|
21908
21924
|
|
|
21909
21925
|
// ../../domains/task-contracts/src/types.ts
|
|
21910
|
-
var COLD_RESPAWN_MS = 30 * 60 * 1e3;
|
|
21911
21926
|
var px = (value) => ({ value, unit: "px" });
|
|
21912
21927
|
var PANEL_LAYOUT_DEFAULTS = {
|
|
21913
21928
|
terminal: { unit: "fr", value: 1, min: px(200), align: "left" },
|
|
@@ -22874,6 +22889,9 @@ function prepareProjectCreate(input) {
|
|
|
22874
22889
|
};
|
|
22875
22890
|
}
|
|
22876
22891
|
|
|
22892
|
+
// ../../shared/platform/src/computer-identity.ts
|
|
22893
|
+
var DEFAULT_LOCAL_COMPUTER_NAME = "local-computer";
|
|
22894
|
+
|
|
22877
22895
|
// src/commands/projects.ts
|
|
22878
22896
|
var DEFAULT_PROJECT_COLOR = "#3b82f6";
|
|
22879
22897
|
function narrowProject(p) {
|
|
@@ -22882,6 +22900,7 @@ function narrowProject(p) {
|
|
|
22882
22900
|
name: p.name,
|
|
22883
22901
|
color: p.color,
|
|
22884
22902
|
path: p.path ?? null,
|
|
22903
|
+
computer_id: p.resolved_computer_id ?? null,
|
|
22885
22904
|
created_at: p.created_at,
|
|
22886
22905
|
updated_at: p.updated_at
|
|
22887
22906
|
};
|
|
@@ -22915,6 +22934,52 @@ function ensureProjectPath(projectPath) {
|
|
|
22915
22934
|
}
|
|
22916
22935
|
return !existedBefore;
|
|
22917
22936
|
}
|
|
22937
|
+
async function resolveHubComputer(ref) {
|
|
22938
|
+
const computers = await apiGet("/api/computers");
|
|
22939
|
+
const wanted = ref.trim().toLowerCase();
|
|
22940
|
+
const exact = computers.find((c) => c.id === ref.trim());
|
|
22941
|
+
const byName = computers.filter((c) => c.name.toLowerCase() === wanted);
|
|
22942
|
+
const byPrefix = computers.filter((c) => c.id.toLowerCase().startsWith(wanted));
|
|
22943
|
+
const matches = exact ? [exact] : byName.length > 0 ? byName : byPrefix;
|
|
22944
|
+
if (matches.length === 1) return matches[0];
|
|
22945
|
+
const available = computers.length > 0 ? ` Available: ${computers.map((c) => `${c.name} (${c.id.slice(0, 8)})`).join(", ")}` : " This hub has no computers.";
|
|
22946
|
+
console.error(
|
|
22947
|
+
matches.length === 0 ? `No computer matching "${ref}".${available}` : `Ambiguous computer "${ref}".${available}`
|
|
22948
|
+
);
|
|
22949
|
+
process.exit(1);
|
|
22950
|
+
}
|
|
22951
|
+
function isAbsoluteAnywhere(p) {
|
|
22952
|
+
return import_node_path4.default.posix.isAbsolute(p) || import_node_path4.default.win32.isAbsolute(p);
|
|
22953
|
+
}
|
|
22954
|
+
async function prepareFolder(input, computer) {
|
|
22955
|
+
const local = computer === null && await isCoLocatedHub();
|
|
22956
|
+
const trimmed = input?.trim() || null;
|
|
22957
|
+
if (!trimmed) return { path: null, local };
|
|
22958
|
+
if (local) return { path: normalizeProjectPath(trimmed), local };
|
|
22959
|
+
if (!isAbsoluteAnywhere(trimmed)) {
|
|
22960
|
+
const where = computer ? `computer "${computer.name}"` : "the hub\u2019s computer";
|
|
22961
|
+
console.error(
|
|
22962
|
+
`--path must be absolute: it is a folder on ${where}, not on this machine, so it cannot be resolved from here.`
|
|
22963
|
+
);
|
|
22964
|
+
process.exit(1);
|
|
22965
|
+
}
|
|
22966
|
+
return { path: trimmed, local };
|
|
22967
|
+
}
|
|
22968
|
+
function warnUnreadyFolder(project, computer, folder) {
|
|
22969
|
+
if (!folder) return;
|
|
22970
|
+
const computerId = computer?.id ?? project.resolved_computer_id;
|
|
22971
|
+
const placement = (project.placements ?? []).find(
|
|
22972
|
+
(pl) => pl.computer_id === computerId
|
|
22973
|
+
);
|
|
22974
|
+
const name = computer ? `"${computer.name}"` : "the project\u2019s computer";
|
|
22975
|
+
if (placement?.status === "missing") {
|
|
22976
|
+
console.error(
|
|
22977
|
+
`Folder not found on ${name}: ${folder}. Create it there; agents start once it exists.`
|
|
22978
|
+
);
|
|
22979
|
+
} else if (placement?.status === "pending") {
|
|
22980
|
+
console.error(`${name} is offline. The folder is recorded when it connects: ${folder}`);
|
|
22981
|
+
}
|
|
22982
|
+
}
|
|
22918
22983
|
function projectsCommand() {
|
|
22919
22984
|
const cmd = new Command("projects").description("Manage projects").showSuggestionAfterError(true).showHelpAfterError(true);
|
|
22920
22985
|
cmd.command("list").description("List all projects").option("--json", "Output as JSON").action(async (opts) => {
|
|
@@ -22927,65 +22992,98 @@ function projectsCommand() {
|
|
|
22927
22992
|
console.log("No projects found.");
|
|
22928
22993
|
return;
|
|
22929
22994
|
}
|
|
22995
|
+
const computerNames = /* @__PURE__ */ new Map();
|
|
22996
|
+
const computersRes = await apiFetch("/api/computers").catch(() => null);
|
|
22997
|
+
if (computersRes?.ok) {
|
|
22998
|
+
const computers = await computersRes.json().catch(() => []);
|
|
22999
|
+
for (const c of computers) computerNames.set(c.id, c.name);
|
|
23000
|
+
}
|
|
22930
23001
|
const idW = 9;
|
|
22931
23002
|
const nameW = 24;
|
|
22932
|
-
|
|
22933
|
-
console.log(
|
|
23003
|
+
const computerW = 16;
|
|
23004
|
+
console.log(
|
|
23005
|
+
`${"ID".padEnd(idW)} ${"NAME".padEnd(nameW)} TASKS ${"COMPUTER".padEnd(computerW)} PATH`
|
|
23006
|
+
);
|
|
23007
|
+
console.log(
|
|
23008
|
+
`${"-".repeat(idW)} ${"-".repeat(nameW)} ----- ${"-".repeat(computerW)} ${"-".repeat(30)}`
|
|
23009
|
+
);
|
|
22934
23010
|
for (const p of projects) {
|
|
22935
23011
|
const id = String(p.id).slice(0, 8).padEnd(idW);
|
|
22936
23012
|
const name = String(p.name).slice(0, nameW).padEnd(nameW);
|
|
22937
23013
|
const tasks = String(p.task_count).padStart(5);
|
|
22938
|
-
|
|
23014
|
+
const computer = (p.computer_id ? computerNames.get(p.computer_id) ?? p.computer_id.slice(0, 8) : "-").slice(0, computerW).padEnd(computerW);
|
|
23015
|
+
console.log(`${id} ${name} ${tasks} ${computer} ${p.path ?? ""}`);
|
|
22939
23016
|
}
|
|
22940
23017
|
});
|
|
22941
23018
|
cmd.command("create <name>").description("Create a new project").option(
|
|
22942
23019
|
"--path <path>",
|
|
22943
|
-
"Repository path (relative paths are resolved from current directory and auto-created)"
|
|
22944
|
-
).option(
|
|
22945
|
-
|
|
22946
|
-
|
|
22947
|
-
|
|
22948
|
-
|
|
22949
|
-
|
|
22950
|
-
const
|
|
22951
|
-
|
|
22952
|
-
|
|
22953
|
-
|
|
22954
|
-
|
|
22955
|
-
|
|
22956
|
-
|
|
22957
|
-
|
|
22958
|
-
|
|
22959
|
-
|
|
22960
|
-
|
|
22961
|
-
|
|
22962
|
-
|
|
22963
|
-
|
|
22964
|
-
|
|
22965
|
-
|
|
22966
|
-
|
|
23020
|
+
"Repository path (relative paths are resolved from current directory and auto-created). With --computer, or a hub on another machine: an absolute path on that computer, used as is"
|
|
23021
|
+
).option(
|
|
23022
|
+
"--computer <name|id>",
|
|
23023
|
+
"Computer the project runs on (its agents, and the --path folder). Default: the hub picks"
|
|
23024
|
+
).option("--color <hex>", "Project color (#RRGGBB)", DEFAULT_PROJECT_COLOR).option("--json", "Output created project as JSON").action(
|
|
23025
|
+
async (name, opts) => {
|
|
23026
|
+
const computer = opts.computer ? await resolveHubComputer(opts.computer) : null;
|
|
23027
|
+
const folder = await prepareFolder(opts.path, computer);
|
|
23028
|
+
let prepared;
|
|
23029
|
+
try {
|
|
23030
|
+
prepared = prepareProjectCreate({ name, color: opts.color, path: folder.path });
|
|
23031
|
+
} catch (error) {
|
|
23032
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
23033
|
+
console.error(message);
|
|
23034
|
+
process.exit(1);
|
|
23035
|
+
}
|
|
23036
|
+
if (folder.local) {
|
|
23037
|
+
const createdPath = ensureProjectPath(prepared.path);
|
|
23038
|
+
if (createdPath && prepared.path) {
|
|
23039
|
+
console.error(`Created directory: ${prepared.path}`);
|
|
23040
|
+
}
|
|
23041
|
+
}
|
|
23042
|
+
const { data } = await apiPost("/api/projects", {
|
|
23043
|
+
name: prepared.name,
|
|
23044
|
+
color: prepared.color,
|
|
23045
|
+
path: prepared.path,
|
|
23046
|
+
...computer ? { computerId: computer.id } : {}
|
|
23047
|
+
});
|
|
23048
|
+
if (!folder.local) warnUnreadyFolder(data, computer, prepared.path);
|
|
23049
|
+
const project = narrowProject(data);
|
|
23050
|
+
if (opts.json) {
|
|
23051
|
+
console.log(JSON.stringify(project, null, 2));
|
|
23052
|
+
return;
|
|
23053
|
+
}
|
|
23054
|
+
const location = project.path ? ` ${project.path}` : "";
|
|
23055
|
+
const on2 = computer ? ` (on ${computer.name})` : "";
|
|
23056
|
+
console.log(`Created project: ${project.id.slice(0, 8)} ${project.name}${location}${on2}`);
|
|
22967
23057
|
}
|
|
22968
|
-
|
|
22969
|
-
|
|
22970
|
-
|
|
22971
|
-
|
|
23058
|
+
);
|
|
23059
|
+
cmd.command("update <name|id>").description("Update a project").option("--name <name>", "New project name").option("--color <hex>", "New project color (#RRGGBB)").option(
|
|
23060
|
+
"--path <path>",
|
|
23061
|
+
"New repository path. With --computer, or a hub on another machine: an absolute path on that computer"
|
|
23062
|
+
).option(
|
|
23063
|
+
"--computer <name|id>",
|
|
23064
|
+
"Move the project to this computer (its agents run there); --path is its folder there"
|
|
23065
|
+
).option("--json", "Output updated project as JSON").action(
|
|
22972
23066
|
async (proj, opts) => {
|
|
22973
|
-
if (opts.name === void 0 && opts.color === void 0 && opts.path === void 0) {
|
|
22974
|
-
console.error("Provide at least one of --name, --color, --path");
|
|
23067
|
+
if (opts.name === void 0 && opts.color === void 0 && opts.path === void 0 && opts.computer === void 0) {
|
|
23068
|
+
console.error("Provide at least one of --name, --color, --path, --computer");
|
|
22975
23069
|
process.exit(1);
|
|
22976
23070
|
}
|
|
23071
|
+
const computer = opts.computer ? await resolveHubComputer(opts.computer) : null;
|
|
22977
23072
|
const body = {};
|
|
22978
23073
|
if (opts.name !== void 0) body.name = opts.name;
|
|
22979
23074
|
if (opts.color !== void 0) body.color = opts.color;
|
|
23075
|
+
if (computer) body.computerId = computer.id;
|
|
23076
|
+
let folder = null;
|
|
22980
23077
|
if (opts.path !== void 0) {
|
|
22981
|
-
|
|
22982
|
-
if (
|
|
22983
|
-
body.path =
|
|
23078
|
+
folder = await prepareFolder(opts.path, computer);
|
|
23079
|
+
if (folder.local && folder.path) ensureProjectPath(folder.path);
|
|
23080
|
+
body.path = folder.path;
|
|
22984
23081
|
}
|
|
22985
23082
|
const { data } = await apiPatch(
|
|
22986
23083
|
`/api/projects/${encodeURIComponent(proj)}`,
|
|
22987
23084
|
body
|
|
22988
23085
|
);
|
|
23086
|
+
if (folder && !folder.local) warnUnreadyFolder(data, computer, folder.path);
|
|
22989
23087
|
const updated = narrowProject(data);
|
|
22990
23088
|
if (opts.json) {
|
|
22991
23089
|
console.log(JSON.stringify(updated, null, 2));
|
|
@@ -25283,21 +25381,22 @@ ${parts.join(", ")} for "${projectName}"`);
|
|
|
25283
25381
|
console.log(`All ${stats.skipped} skills up to date for "${projectName}"`);
|
|
25284
25382
|
}
|
|
25285
25383
|
}
|
|
25286
|
-
async function
|
|
25287
|
-
if (explicit) return explicit;
|
|
25384
|
+
async function resolveTargetProject(explicit) {
|
|
25385
|
+
if (explicit) return { ref: explicit, localFolder: null };
|
|
25288
25386
|
const { data } = await apiGet(
|
|
25289
25387
|
`/api/projects/resolve-by-path?path=${encodeURIComponent(process.cwd())}`
|
|
25290
25388
|
);
|
|
25291
|
-
return data.id;
|
|
25389
|
+
return { ref: data.id, localFolder: data.path };
|
|
25292
25390
|
}
|
|
25293
25391
|
async function runInstall(opts) {
|
|
25294
|
-
const projectRef = await
|
|
25392
|
+
const { ref: projectRef, localFolder } = await resolveTargetProject(opts.project);
|
|
25295
25393
|
const { data } = await apiPost(
|
|
25296
25394
|
`/api/projects/${encodeURIComponent(projectRef)}/skills`,
|
|
25297
25395
|
{}
|
|
25298
25396
|
);
|
|
25299
25397
|
const { project, providers, stats, skills } = data;
|
|
25300
|
-
const
|
|
25398
|
+
const candidate = localFolder ?? project.path;
|
|
25399
|
+
const localPath = candidate && import_node_fs3.default.existsSync(candidate) ? candidate : null;
|
|
25301
25400
|
if (opts.writeInstructions && localPath) {
|
|
25302
25401
|
const written = writeInstructionsToDisk(localPath, providers);
|
|
25303
25402
|
for (const f of written) console.log(` Appended instructions to ${f}`);
|
|
@@ -26116,11 +26215,6 @@ var import_node_path9 = require("node:path");
|
|
|
26116
26215
|
// ../../shared/platform/src/slayzone-config.ts
|
|
26117
26216
|
var import_node_fs5 = require("node:fs");
|
|
26118
26217
|
var import_node_path6 = require("node:path");
|
|
26119
|
-
|
|
26120
|
-
// ../../shared/platform/src/computer-identity.ts
|
|
26121
|
-
var DEFAULT_LOCAL_COMPUTER_NAME = "local-computer";
|
|
26122
|
-
|
|
26123
|
-
// ../../shared/platform/src/slayzone-config.ts
|
|
26124
26218
|
var HUB_CONFIG_SWITCH_KEYS = [
|
|
26125
26219
|
"requireLogin",
|
|
26126
26220
|
"enablePassword",
|
|
@@ -26540,7 +26634,7 @@ var import_node_child_process3 = require("node:child_process");
|
|
|
26540
26634
|
var import_node_fs7 = require("node:fs");
|
|
26541
26635
|
var import_node_module = require("node:module");
|
|
26542
26636
|
var import_node_path8 = require("node:path");
|
|
26543
|
-
var CLI_VERSION = true ? "0.36.
|
|
26637
|
+
var CLI_VERSION = true ? "0.36.4" : "";
|
|
26544
26638
|
function fail(message) {
|
|
26545
26639
|
console.error(message);
|
|
26546
26640
|
process.exit(1);
|
|
@@ -26977,6 +27071,25 @@ function postJson2(transport, url, body, timeoutMs) {
|
|
|
26977
27071
|
});
|
|
26978
27072
|
}
|
|
26979
27073
|
|
|
27074
|
+
// ../../domains/hub-auth/src/client/sign-in-error.ts
|
|
27075
|
+
var ASK_ADMIN = "If it keeps failing, ask your administrator.";
|
|
27076
|
+
var MESSAGES2 = {
|
|
27077
|
+
// T-09 refuses every ID token that fails its checks with this generic code: another
|
|
27078
|
+
// tenant, no MFA, no SlayZone app role, no email (the audit line names which).
|
|
27079
|
+
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.",
|
|
27080
|
+
ACCOUNT_DISABLED: "This account is disabled on this hub. Ask your administrator.",
|
|
27081
|
+
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.",
|
|
27082
|
+
unable_to_link_account: "This Microsoft account could not be connected to an account on this hub. Ask your administrator.",
|
|
27083
|
+
access_denied: "Sign-in was cancelled at Microsoft. Try again.",
|
|
27084
|
+
state_mismatch: "The sign-in took too long or was started in another tab. Try again.",
|
|
27085
|
+
please_restart_the_process: "The sign-in took too long or was started in another tab. Try again.",
|
|
27086
|
+
invalid_callback_request: "The sign-in took too long or was started in another tab. Try again.",
|
|
27087
|
+
no_session: `Microsoft sign-in did not complete. Try again. ${ASK_ADMIN}`,
|
|
27088
|
+
// App sign-in (`src/server/app-sign-in.ts`).
|
|
27089
|
+
flow_expired: "The sign-in took too long or its browser window was closed. Try again.",
|
|
27090
|
+
temporarily_unavailable: "Too many sign-ins are waiting on this hub. Try again in a few minutes."
|
|
27091
|
+
};
|
|
27092
|
+
|
|
26980
27093
|
// ../../domains/hub-auth/src/client/health.ts
|
|
26981
27094
|
async function fetchHubHealth(transport, baseUrl, timeoutMs) {
|
|
26982
27095
|
try {
|
|
@@ -27163,22 +27276,6 @@ async function fetchSessionEmail(transport, baseUrl, token, timeoutMs = AUTH_TIM
|
|
|
27163
27276
|
}
|
|
27164
27277
|
}
|
|
27165
27278
|
|
|
27166
|
-
// ../../domains/hub-auth/src/client/sign-in-error.ts
|
|
27167
|
-
var ASK_ADMIN = "If it keeps failing, ask your administrator.";
|
|
27168
|
-
var MESSAGES2 = {
|
|
27169
|
-
// T-09 refuses every ID token that fails its checks with this generic code: another
|
|
27170
|
-
// tenant, no MFA, no SlayZone app role, no email (the audit line names which).
|
|
27171
|
-
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.",
|
|
27172
|
-
ACCOUNT_DISABLED: "This account is disabled on this hub. Ask your administrator.",
|
|
27173
|
-
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.",
|
|
27174
|
-
unable_to_link_account: "This Microsoft account could not be connected to an account on this hub. Ask your administrator.",
|
|
27175
|
-
access_denied: "Sign-in was cancelled at Microsoft. Try again.",
|
|
27176
|
-
state_mismatch: "The sign-in took too long or was started in another tab. Try again.",
|
|
27177
|
-
please_restart_the_process: "The sign-in took too long or was started in another tab. Try again.",
|
|
27178
|
-
invalid_callback_request: "The sign-in took too long or was started in another tab. Try again.",
|
|
27179
|
-
no_session: `Microsoft sign-in did not complete. Try again. ${ASK_ADMIN}`
|
|
27180
|
-
};
|
|
27181
|
-
|
|
27182
27279
|
// ../../domains/hub-auth/src/client-node/index.ts
|
|
27183
27280
|
var import_node_http3 = __toESM(require("node:http"), 1);
|
|
27184
27281
|
var import_node_https = __toESM(require("node:https"), 1);
|
|
@@ -27834,6 +27931,8 @@ function describeTargetSource(target) {
|
|
|
27834
27931
|
switch (target.source) {
|
|
27835
27932
|
case "flag":
|
|
27836
27933
|
return "--hub";
|
|
27934
|
+
case "relay":
|
|
27935
|
+
return "authenticated computer CLI relay";
|
|
27837
27936
|
case "break-glass":
|
|
27838
27937
|
return `break-glass session, ${getBreakGlassSessionPath()}`;
|
|
27839
27938
|
case "env":
|
|
@@ -27844,10 +27943,13 @@ function describeTargetSource(target) {
|
|
|
27844
27943
|
}
|
|
27845
27944
|
async function probeHealth(target) {
|
|
27846
27945
|
try {
|
|
27847
|
-
const res = await fetch(
|
|
27848
|
-
|
|
27849
|
-
|
|
27850
|
-
|
|
27946
|
+
const res = await fetch(
|
|
27947
|
+
`${target.baseUrl}${target.source === "relay" ? "/api/computers" : "/health"}`,
|
|
27948
|
+
{
|
|
27949
|
+
headers: target.token ? { Authorization: `Bearer ${target.token}` } : {},
|
|
27950
|
+
signal: AbortSignal.timeout(5e3)
|
|
27951
|
+
}
|
|
27952
|
+
);
|
|
27851
27953
|
return res.ok ? { ok: true, line: `Health: ok (HTTP ${res.status})` } : { ok: false, line: `Health: failed (HTTP ${res.status})` };
|
|
27852
27954
|
} catch {
|
|
27853
27955
|
return { ok: false, line: `Health: unreachable (could not connect to ${target.baseUrl})` };
|
|
@@ -27855,14 +27957,23 @@ async function probeHealth(target) {
|
|
|
27855
27957
|
}
|
|
27856
27958
|
function hubCommand() {
|
|
27857
27959
|
const cmd = new Command("hub").description("Run, list and target SlayZone hubs").showSuggestionAfterError(true).showHelpAfterError(true);
|
|
27858
|
-
cmd.command("ls").description("List
|
|
27960
|
+
cmd.command("ls").description("List local hubs and the remote task hub target").option("--json", "Output as JSON").option("--json-v2", "Output versioned JSON including the task hub target").action(async (opts) => {
|
|
27859
27961
|
const hubs = await discoverAllHubs();
|
|
27962
|
+
const target = isTaskTerminal() ? resolveTaskCommandTarget() : null;
|
|
27963
|
+
const url = target?.hubUrl ?? target?.baseUrl;
|
|
27964
|
+
const taskHub = url ? { url, connection: target.source === "relay" ? "relay" : "configured", verified: false } : null;
|
|
27965
|
+
if (opts.jsonV2) {
|
|
27966
|
+
console.log(JSON.stringify({ version: 2, hubs, taskHub }, null, 2));
|
|
27967
|
+
return;
|
|
27968
|
+
}
|
|
27860
27969
|
if (opts.json) {
|
|
27861
27970
|
console.log(JSON.stringify(hubs, null, 2));
|
|
27862
27971
|
return;
|
|
27863
27972
|
}
|
|
27864
27973
|
if (hubs.length === 0) {
|
|
27865
|
-
|
|
27974
|
+
if (taskHub)
|
|
27975
|
+
console.log(`Task hub: ${taskHub.url} (${taskHub.connection}; connection not checked)`);
|
|
27976
|
+
else console.log("No hubs running. Create one with `slay hub create <name>`.");
|
|
27866
27977
|
return;
|
|
27867
27978
|
}
|
|
27868
27979
|
const nameW = Math.max(4, ...hubs.map((h) => h.name.length));
|
|
@@ -27884,6 +27995,9 @@ function hubCommand() {
|
|
|
27884
27995
|
`${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}`
|
|
27885
27996
|
);
|
|
27886
27997
|
}
|
|
27998
|
+
if (taskHub)
|
|
27999
|
+
console.log(`
|
|
28000
|
+
Task hub: ${taskHub.url} (${taskHub.connection}; connection not checked)`);
|
|
27887
28001
|
});
|
|
27888
28002
|
cmd.command("create <name>").description("Create a hub here and keep it running (crash-restart + start at login)").option("--root <dir>", "Hub root \u2014 its config, storage and logs (default: cwd)").option("--port <port>", "Bind a specific port (default: first free hub port)").option(
|
|
27889
28003
|
"--public-address <host[:port]>",
|
|
@@ -28219,7 +28333,7 @@ then \`slay hub start ${name}\`.`
|
|
|
28219
28333
|
console.log(` Hub: ${none}`);
|
|
28220
28334
|
continue;
|
|
28221
28335
|
}
|
|
28222
|
-
console.log(` Hub: ${target.baseUrl}`);
|
|
28336
|
+
console.log(` Hub: ${target.hubUrl ?? target.baseUrl}`);
|
|
28223
28337
|
console.log(` Source: ${describeTargetSource(target)}`);
|
|
28224
28338
|
console.log(` Token: ${target.token ? "set" : "not set"}`);
|
|
28225
28339
|
const key = `${target.baseUrl}
|
|
@@ -29102,7 +29216,7 @@ function updateCommand() {
|
|
|
29102
29216
|
}
|
|
29103
29217
|
|
|
29104
29218
|
// src/index.ts
|
|
29105
|
-
var program2 = new Command().name("slay").description("SlayZone CLI").version("0.36.
|
|
29219
|
+
var program2 = new Command().name("slay").description("SlayZone CLI").version("0.36.4").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) => {
|
|
29106
29220
|
const root = thisCommand.parent ?? thisCommand;
|
|
29107
29221
|
const opts = root.opts();
|
|
29108
29222
|
if (opts.dev) process.env.SLAYZONE_DEV = "1";
|