@sealant/mend 0.36.0-next.754 → 0.36.0-next.761
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/README.md +17 -8
- package/dist/{chunk-ARGA4E7A.js → chunk-D4JBBLJV.js} +77 -3
- package/dist/{dashboard-JGR77HVG.js → dashboard-4BJL72T6.js} +16 -27
- package/dist/main.js +659 -214
- package/man/mend-accounts.1 +1 -1
- package/man/mend-adopt.1 +1 -1
- package/man/mend-attach.1 +1 -1
- package/man/mend-codex.1 +1 -1
- package/man/mend-completions.1 +1 -1
- package/man/mend-connect-pi.1 +1 -1
- package/man/mend-connect.1 +1 -1
- package/man/mend-continue.1 +1 -1
- package/man/mend-doctor.1 +1 -1
- package/man/mend-dotfiles-repo.1 +1 -1
- package/man/mend-dotfiles-sync.1 +1 -1
- package/man/mend-dotfiles.1 +1 -1
- package/man/mend-env-cluster.1 +1 -1
- package/man/mend-env-load.1 +1 -1
- package/man/mend-env-show.1 +1 -1
- package/man/mend-folder-create.1 +1 -1
- package/man/mend-folder-list.1 +1 -1
- package/man/mend-folder-push.1 +1 -1
- package/man/mend-folder-rm.1 +1 -1
- package/man/mend-git-author.1 +1 -1
- package/man/mend-help.1 +1 -1
- package/man/mend-invite.1 +1 -1
- package/man/mend-keys-init.1 +1 -1
- package/man/mend-keys-mode.1 +1 -1
- package/man/mend-keys-share.1 +1 -1
- package/man/mend-keys-show.1 +1 -1
- package/man/mend-land.1 +1 -1
- package/man/mend-login.1 +1 -1
- package/man/mend-logout.1 +1 -1
- package/man/mend-logs.1 +1 -1
- package/man/mend-man.1 +1 -1
- package/man/mend-members.1 +1 -1
- package/man/mend-memory-import.1 +1 -1
- package/man/mend-memory-rm.1 +1 -1
- package/man/mend-memory-show.1 +1 -1
- package/man/mend-memory.1 +1 -1
- package/man/mend-models.1 +1 -1
- package/man/mend-operator-exposure.1 +1 -1
- package/man/mend-operator-gate.1 +1 -1
- package/man/mend-operator-grant-owner.1 +1 -1
- package/man/mend-operator-org-create.1 +1 -1
- package/man/mend-operator-org-invite-owner.1 +1 -1
- package/man/mend-operator-org-list.1 +1 -1
- package/man/mend-operator-org-rename.1 +1 -1
- package/man/mend-operator-reset-link.1 +1 -1
- package/man/mend-pair.1 +1 -1
- package/man/mend-projects.1 +1 -1
- package/man/mend-pull.1 +1 -1
- package/man/mend-refresh.1 +1 -1
- package/man/mend-rejoin.1 +1 -1
- package/man/mend-resume.1 +1 -1
- package/man/mend-run.1 +1 -1
- package/man/mend-secrets-add.1 +1 -1
- package/man/mend-secrets-rm.1 +1 -1
- package/man/mend-secrets.1 +1 -1
- package/man/mend-server-logs.1 +1 -1
- package/man/mend-server-restart.1 +1 -1
- package/man/mend-server-setup.1 +6 -4
- package/man/mend-server-start.1 +1 -1
- package/man/mend-server-status.1 +1 -1
- package/man/mend-server-stop.1 +1 -1
- package/man/mend-server-upgrade.1 +1 -1
- package/man/mend-server.1 +1 -1
- package/man/mend-service-add.1 +1 -1
- package/man/mend-service-connect.1 +1 -1
- package/man/mend-service-init.1 +1 -1
- package/man/mend-service-list.1 +1 -1
- package/man/mend-service-logs.1 +1 -1
- package/man/mend-service-restart.1 +1 -1
- package/man/mend-service-run.1 +1 -1
- package/man/mend-service-stop.1 +1 -1
- package/man/mend-session-share.1 +1 -1
- package/man/mend-sessions.1 +1 -1
- package/man/mend-shell.1 +1 -1
- package/man/mend-skills-push.1 +1 -1
- package/man/mend-skills.1 +1 -1
- package/man/mend-snake.1 +1 -1
- package/man/mend-ssh-keys-remove.1 +1 -1
- package/man/mend-ssh-keys.1 +1 -1
- package/man/mend-ssh-setup.1 +1 -1
- package/man/mend-ssh.1 +12 -3
- package/man/mend-stop.1 +1 -1
- package/man/mend-ui.1 +1 -1
- package/man/mend-uninstall.1 +1 -1
- package/man/mend-version.1 +1 -1
- package/man/mend-wait.1 +1 -1
- package/man/mend-workspace-replace.1 +1 -1
- package/man/mend-worktrees-rm.1 +1 -1
- package/man/mend-worktrees.1 +1 -1
- package/man/mend.1 +2 -2
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
AGENT_MEMORY_FILES,
|
|
4
3
|
AGENT_MEMORY_MAX_DATABASE_BYTES,
|
|
5
4
|
AGENT_MEMORY_MAX_FILE_BYTES,
|
|
6
5
|
AGENT_MEMORY_ROOTS,
|
|
@@ -19,8 +18,10 @@ import {
|
|
|
19
18
|
PI_PROFILE_MAX_FILE_BYTES,
|
|
20
19
|
REPLACE_WORKSPACE_ACTION,
|
|
21
20
|
WORKTREE_REMOVAL_FORCE_HINT,
|
|
21
|
+
adoptedGitAuth,
|
|
22
22
|
agentIsLive,
|
|
23
23
|
agentMemoryNameOf,
|
|
24
|
+
agentMemoryPathOf,
|
|
24
25
|
agentStartingFacts,
|
|
25
26
|
agentStartingLine,
|
|
26
27
|
askYesNo,
|
|
@@ -79,7 +80,7 @@ import {
|
|
|
79
80
|
workspaceRetirementLine,
|
|
80
81
|
worktreeJoinLine,
|
|
81
82
|
worktreeListsPeople
|
|
82
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-D4JBBLJV.js";
|
|
83
84
|
|
|
84
85
|
// src/main.ts
|
|
85
86
|
import { spawn as spawn3, spawnSync as spawnSync6 } from "node:child_process";
|
|
@@ -87,7 +88,7 @@ import * as crypto from "node:crypto";
|
|
|
87
88
|
import * as fs21 from "node:fs";
|
|
88
89
|
import { createRequire } from "node:module";
|
|
89
90
|
import * as net6 from "node:net";
|
|
90
|
-
import * as
|
|
91
|
+
import * as os14 from "node:os";
|
|
91
92
|
import * as path21 from "node:path";
|
|
92
93
|
|
|
93
94
|
// src/agent-memory.ts
|
|
@@ -3298,7 +3299,8 @@ var COMMANDS = [
|
|
|
3298
3299
|
],
|
|
3299
3300
|
description: [
|
|
3300
3301
|
"On a terminal with no flags, setup asks its questions in plain words, one at a time: how people reach this Mend (just this machine, your private network or Tailscale, or the public internet with HTTPS), whether VS Code Remote-SSH reaches it from other machines, the T3 Code gateway, the mirrors, and one organization or several. It looks before it asks and says what it observed: Tailscale's name and address and what Tailscale Serve forwards, where your domain resolves, and whether ports 80 and 443 are taken. It never asks for an address to bind: that follows from the answers. On an existing install it shows what is saved and lets you keep it, change one thing, or go through every question. It ends with what changes, in words, and the same command with flags; nothing applies until you say yes.",
|
|
3301
|
-
"Flags are for scripts and CI, and teach what the questions do. Each changes only what it names; everything else is kept from the saved install, so mend server setup --t3-gateway turns the gateway on and nothing more. When there is an install, a run with flags says what it changes. With no terminal and no flags, a fresh install is refused rather than guessed: --yes takes the defaults.",
|
|
3302
|
+
"Flags are for scripts and CI, and teach what the questions do. Each changes only what it names; everything else is kept from the saved install, so mend server setup --t3-gateway turns the gateway on and nothing more. When there is an install, a run with flags says what it changes. With no terminal and no flags, a fresh install is refused rather than guessed: --yes takes the defaults. --context and --docker-socket choose the Docker engine and answer no question, so with only those (on a Mac with Docker Desktop and OrbStack, --context orbstack) setup still asks its questions. A fresh install without --context takes DOCKER_CONTEXT, as docker does; an existing one stays on the context its data is on.",
|
|
3303
|
+
"Before anything is pulled, setup checks that Mend's web and SSH ports are free where they are to be published, and says what holds one that is not: another Mend, with its version, or something else. On a terminal it offers the next free port; with flags it refuses and names --port or --ssh-port. After starting, it reads health until this install answers: its version, and the instance id the server reports, so another Mend on the same port is said as one, never taken for this one.",
|
|
3302
3304
|
"Checks a local Unix-socket Docker context and the Compose plugin, downloads the compose and Postgres initialization assets for one Mend release, preserves existing data and secrets, and starts the server. Re-running repairs the same pinned version. A changed --version is refused; use mend server upgrade. Updating this CLI never updates an existing server pin.",
|
|
3303
3305
|
"The default listens only on localhost at http://localhost:3105. Non-local access requires both --bind and --url. Every extra browser origin must be named with --origin; setup never guesses from the request Host header or network interfaces. A fresh install refuses a public --bind address: until the first account exists, registration is open to whoever reaches it first. On an existing install, setup says when Mend's port or workspace SSH is published on a public address while the exposure is not public. The questions offer only private addresses (a tailnet, a LAN or VPN, carrier-grade NAT space) for a private network.",
|
|
3304
3306
|
"--edge <host> runs a TLS edge in front of Mend: Caddy on ports 80 and 443 of every interface, which obtains and renews a certificate for the host and proxies to Mend's web tier. Mend's own port stays on loopback and the browser origin is https://<host>. The edge's compose overlay and Caddyfile are written into the generation beside compose.yaml, so start, restart and upgrade run them every time. --no-edge takes it away again, and the edge's container with it. A fresh install cannot start with the edge: until the first account exists, registration is open to whoever reaches the origin first, so set up on localhost, create the account, then add the edge.",
|
|
@@ -3306,7 +3308,7 @@ var COMMANDS = [
|
|
|
3306
3308
|
"--exposure declares how the instance is reached, and --tenancy whether one organization or many use it. Both are written into the generation and kept across reruns and upgrades. public needs the edge and an existing first account. With multi, or with public, the multi mode gate's settings follow: MEND_SOURCE_POLICY=tenant and MEND_CAPTURE_REQUIRE_SIZES=true, and public sets MEND_URL_BEARERS=refuse. The server still decides whether it starts, and mend server status shows what it reports.",
|
|
3307
3309
|
"Two mirrors run beside Mend unless turned off: an npm mirror (nginx caching npmjs.org, capped at 10g by default, least recently used out) and a Docker mirror (a pull-through cache of Docker Hub, capped at 20g by default: over the cap its cache is cleared). Both leave 5g free on their disk: below that, nginx evicts and the Docker mirror pauses, and sessions pull from Docker Hub directly. Neither publishes a host port. Sessions install npm packages and pull Docker Hub images through them; a project's own npm settings win, and a mirror that is down sends sessions upstream instead. Both are kept across reruns and upgrades, and an upgrade adds them to an install from before them. The Docker mirror pulls anonymously unless given a Docker Hub login: --docker-hub-username with the access token piped on standard input, kept in server.env only. The mirror has no login of its own, so every session that reaches it can pull whatever that token can read: setup takes a login only with --docker-hub-public-only, your statement that the token's access permission is Public Repo Read-only. Mend cannot check a token's scope.",
|
|
3308
3310
|
"Before anything is pulled, setup reads the Docker host's kernel. Each workspace runs its own rootless Docker, which needs unprivileged user namespaces; Ubuntu 23.10 and later (24.04 LTS included) refuse them by default, and then no session can start. On a terminal setup asks to allow them: on a yes it writes the setting to /etc/sysctl.d/60-mend-rootless-docker.conf on the Docker host and applies it, through a short privileged container on the Docker socket it already uses, then reads the kernel again. That lifts the restriction for the whole host; the file says on its first lines that setup wrote it and what it replaced, so mend uninstall --all removes it and puts that back. On a no, without a terminal, or on a rootless daemon, it prints the command to run on the host, and repeats it as its last line. --allow-userns and --no-allow-userns answer for a script.",
|
|
3309
|
-
"When setup changes Mend's URL, a CLI signed in at the old one is left pointing there. Setup says so with the command each one runs (mend login --url <new>). When this machine's own CLI points at the old URL and that no longer answers, setup offers to point it at the new one; its sign-in carries over, since a device's token is not bound to a URL. A re-run says to create the first account only while the instance has none.",
|
|
3311
|
+
"When setup changes Mend's URL, a CLI signed in at the old one is left pointing there. Setup says so with the command each one runs (mend login --url <new>). When this machine's own CLI points at the old URL and that no longer answers, setup offers to point it at the new one; its sign-in carries over, since a device's token is not bound to a URL. When it points anywhere else this install does not answer (another server, or nothing), setup offers the same; a sign-in made at another server stays behind, and the offer leads with no while that server answers. A re-run says to create the first account only while the instance has none.",
|
|
3310
3312
|
"Docker Desktop on Linux and macOS, and OrbStack on macOS, expose client-side proxy sockets. Containers use the daemon-side /var/run/docker.sock. --docker-socket overrides detection and is retained on reruns.",
|
|
3311
3313
|
"Setup holds an exclusive process lock through startup and health checks. A busy lock reports its owner and manual recovery steps. Never remove a live lock. Private configuration uses immutable generations and an atomic active pointer; failed attempts retain credentials and never delete Docker volumes."
|
|
3312
3314
|
],
|
|
@@ -3317,7 +3319,7 @@ var COMMANDS = [
|
|
|
3317
3319
|
},
|
|
3318
3320
|
{
|
|
3319
3321
|
flag: "--context <name>",
|
|
3320
|
-
text: "local Docker context to persist; the global context is unchanged"
|
|
3322
|
+
text: "local Docker context to persist; the global context is unchanged. Answers no question. Default: DOCKER_CONTEXT on a fresh install, else the saved one"
|
|
3321
3323
|
},
|
|
3322
3324
|
{
|
|
3323
3325
|
flag: "--version <v>",
|
|
@@ -3558,9 +3560,13 @@ var COMMANDS = [
|
|
|
3558
3560
|
{
|
|
3559
3561
|
name: "ssh",
|
|
3560
3562
|
section: "this machine",
|
|
3561
|
-
summary: "workspace SSH status
|
|
3562
|
-
synopsis: ["[status]"],
|
|
3563
|
-
description: [
|
|
3563
|
+
summary: "workspace SSH status, or the ssh command for one session",
|
|
3564
|
+
synopsis: ["[status]", "<session> [--host <hostname>]"],
|
|
3565
|
+
description: [
|
|
3566
|
+
"Without a session: whether this machine can ssh into workspaces, and what is missing if not.",
|
|
3567
|
+
"With a session id or its prefix: the exact ssh command that reaches that session's workspace, on its own line, e.g. ssh ws-<workspace>@mend-ws-\u2026. The user is the workspace's id, which no other command shows; a Docker container name is a different id, and the gateway closes the connection after its banner. A session with no running workspace is refused."
|
|
3568
|
+
],
|
|
3569
|
+
examples: [{ command: "mend ssh 3f2a9c1e", text: "print the ssh command for that session" }],
|
|
3564
3570
|
see: ["ssh setup", "ssh keys"]
|
|
3565
3571
|
},
|
|
3566
3572
|
{
|
|
@@ -4389,19 +4395,25 @@ var observeDockerd = (proc, host) => {
|
|
|
4389
4395
|
why: only === void 0 ? `${seen} \xB7 none observed serving ${socket}` : `${seen} \xB7 could not tell which serves ${socket}`
|
|
4390
4396
|
};
|
|
4391
4397
|
};
|
|
4392
|
-
var hostDockerEndpoint = () => {
|
|
4393
|
-
const fromEnv = process.env["DOCKER_HOST"];
|
|
4398
|
+
var hostDockerEndpoint = (context = null) => {
|
|
4399
|
+
const fromEnv = context === null ? process.env["DOCKER_HOST"] : void 0;
|
|
4394
4400
|
if (fromEnv !== void 0 && fromEnv.trim() !== "") return fromEnv.trim();
|
|
4395
|
-
const
|
|
4401
|
+
const inspected = spawnSync3(
|
|
4396
4402
|
"docker",
|
|
4397
|
-
[
|
|
4403
|
+
[
|
|
4404
|
+
"context",
|
|
4405
|
+
"inspect",
|
|
4406
|
+
...context === null ? [] : [context],
|
|
4407
|
+
"--format",
|
|
4408
|
+
"{{.Endpoints.docker.Host}}"
|
|
4409
|
+
],
|
|
4398
4410
|
{
|
|
4399
4411
|
encoding: "utf8",
|
|
4400
4412
|
timeout: 3e3,
|
|
4401
4413
|
stdio: ["ignore", "pipe", "ignore"]
|
|
4402
4414
|
}
|
|
4403
4415
|
);
|
|
4404
|
-
const endpoint =
|
|
4416
|
+
const endpoint = inspected.status === 0 ? inspected.stdout.trim() : "";
|
|
4405
4417
|
return endpoint === "" ? DOCKER_DEFAULT_HOST : endpoint;
|
|
4406
4418
|
};
|
|
4407
4419
|
var dockerdFactsOf = (observation) => {
|
|
@@ -4414,20 +4426,26 @@ var dockerdFactsOf = (observation) => {
|
|
|
4414
4426
|
return { dockerdArgv: null, dockerdUnresolved: observation.why };
|
|
4415
4427
|
}
|
|
4416
4428
|
};
|
|
4417
|
-
var hostDockerDaemonFacts = (infoStdout) => ({
|
|
4429
|
+
var hostDockerDaemonFacts = (infoStdout, context = null) => ({
|
|
4418
4430
|
info: infoStdout === null ? null : parseDockerInfo(infoStdout),
|
|
4419
|
-
...dockerdFactsOf(observeDockerd(hostProcView, hostDockerEndpoint())),
|
|
4431
|
+
...dockerdFactsOf(observeDockerd(hostProcView, hostDockerEndpoint(context))),
|
|
4420
4432
|
readFile: readHostFile,
|
|
4421
4433
|
home: os5.homedir(),
|
|
4422
4434
|
xdgConfigHome: process.env["XDG_CONFIG_HOME"] ?? null
|
|
4423
4435
|
});
|
|
4424
|
-
var observeHostShutdownTimeout = () => {
|
|
4425
|
-
const info = spawnSync3(
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4436
|
+
var observeHostShutdownTimeout = (context = null) => {
|
|
4437
|
+
const info = spawnSync3(
|
|
4438
|
+
"docker",
|
|
4439
|
+
[...context === null ? [] : ["--context", context], "info", "--format", "{{json .}}"],
|
|
4440
|
+
{
|
|
4441
|
+
encoding: "utf8",
|
|
4442
|
+
timeout: 3e3,
|
|
4443
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
4444
|
+
}
|
|
4445
|
+
);
|
|
4446
|
+
return readShutdownTimeout(
|
|
4447
|
+
hostDockerDaemonFacts(info.status === 0 ? info.stdout : null, context)
|
|
4448
|
+
);
|
|
4431
4449
|
};
|
|
4432
4450
|
|
|
4433
4451
|
// src/doctor.ts
|
|
@@ -4462,7 +4480,7 @@ var exposureCheck = (exposure) => {
|
|
|
4462
4480
|
label: "exposure",
|
|
4463
4481
|
state: plainBeyondMachine ? "todo" : "ok",
|
|
4464
4482
|
detail: facts,
|
|
4465
|
-
fix: plainBeyondMachine ? "serve it over https
|
|
4483
|
+
fix: plainBeyondMachine ? "serve it over https: on the server's machine, mend server setup --edge <domain>, or mend server setup --url https://<origin> behind HTTPS you run" : gateOpen === 0 ? null : "mend operator exposure"
|
|
4466
4484
|
};
|
|
4467
4485
|
};
|
|
4468
4486
|
var userNamespacesCheck = (observed) => observed.allowed ? {
|
|
@@ -4500,16 +4518,15 @@ var identityOf = (account) => {
|
|
|
4500
4518
|
}
|
|
4501
4519
|
return null;
|
|
4502
4520
|
};
|
|
4503
|
-
var unreachedServer = async (config,
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
const there = await getJson({ url: local, token: null }, "/health");
|
|
4521
|
+
var unreachedServer = async (config, local) => {
|
|
4522
|
+
if (local !== null && local.url !== config.url) {
|
|
4523
|
+
const there = await getJson({ url: local.url, token: null }, "/health");
|
|
4507
4524
|
if (there.value !== null) {
|
|
4508
4525
|
return {
|
|
4509
4526
|
label: "server",
|
|
4510
4527
|
state: "failed",
|
|
4511
|
-
detail: `cannot reach ${config.url} \xB7 the Mend server on this machine answers at ${local}, and this CLI points at the old URL`,
|
|
4512
|
-
fix: `mend login --url ${local}`
|
|
4528
|
+
detail: `cannot reach ${config.url} \xB7 the Mend server on this machine answers at ${local.url}, and this CLI points at the old URL`,
|
|
4529
|
+
fix: `mend login --url ${local.url}`
|
|
4513
4530
|
};
|
|
4514
4531
|
}
|
|
4515
4532
|
}
|
|
@@ -4520,16 +4537,39 @@ var unreachedServer = async (config, probes) => {
|
|
|
4520
4537
|
fix: "start the Mend server (mend server start on its machine), or, if its URL changed, mend login --url <its URL>"
|
|
4521
4538
|
};
|
|
4522
4539
|
};
|
|
4540
|
+
var isLoopbackUrl = (url) => {
|
|
4541
|
+
try {
|
|
4542
|
+
const host = new URL(url).hostname;
|
|
4543
|
+
return host === "localhost" || host === "[::1]" || host.startsWith("127.");
|
|
4544
|
+
} catch {
|
|
4545
|
+
return false;
|
|
4546
|
+
}
|
|
4547
|
+
};
|
|
4548
|
+
var answeredServer = async (config, health, local) => {
|
|
4549
|
+
const ok = {
|
|
4550
|
+
label: "server",
|
|
4551
|
+
state: "ok",
|
|
4552
|
+
detail: `${config.url} \xB7 mend ${health.version}`,
|
|
4553
|
+
fix: null
|
|
4554
|
+
};
|
|
4555
|
+
if (local === null || local.url === config.url || !isLoopbackUrl(config.url)) return ok;
|
|
4556
|
+
const same = health.instance === void 0 ? health.version === local.version : health.instance === local.instance;
|
|
4557
|
+
if (same) return ok;
|
|
4558
|
+
const there = await getJson({ url: local.url, token: null }, "/health");
|
|
4559
|
+
if (there.value === null) return ok;
|
|
4560
|
+
return {
|
|
4561
|
+
label: "server",
|
|
4562
|
+
state: "todo",
|
|
4563
|
+
detail: `${config.url} \xB7 mend ${health.version} \xB7 not the server installed on this machine, which answers at ${local.url} (mend ${there.value.version})`,
|
|
4564
|
+
fix: `mend login --url ${local.url}`
|
|
4565
|
+
};
|
|
4566
|
+
};
|
|
4523
4567
|
var runChecks = async (config, probes) => {
|
|
4524
4568
|
const checks = [];
|
|
4525
4569
|
const health = await getJson(config, "/health");
|
|
4570
|
+
const local = probes.localServer === void 0 ? null : await probes.localServer();
|
|
4526
4571
|
checks.push(
|
|
4527
|
-
health.value === null ? await unreachedServer(config,
|
|
4528
|
-
label: "server",
|
|
4529
|
-
state: "ok",
|
|
4530
|
-
detail: `${config.url} \xB7 mend ${health.value.version}`,
|
|
4531
|
-
fix: null
|
|
4532
|
-
}
|
|
4572
|
+
health.value === null ? await unreachedServer(config, local) : await answeredServer(config, health.value, local)
|
|
4533
4573
|
);
|
|
4534
4574
|
const projects = health.value !== null && config.token !== null ? await getJson(config, "/projects") : null;
|
|
4535
4575
|
if (health.value === null) checks.push(notChecked("signed in"));
|
|
@@ -4675,7 +4715,7 @@ var runChecks = async (config, probes) => {
|
|
|
4675
4715
|
const userNamespaces = machine === null || machine.value === null ? void 0 : machine.value.userNamespaces;
|
|
4676
4716
|
if (userNamespaces !== void 0) checks.push(userNamespacesCheck(userNamespaces));
|
|
4677
4717
|
if (probes.dockerShutdown !== void 0 && probes.onPath("docker")) {
|
|
4678
|
-
checks.push(dockerShutdownCheck(probes.dockerShutdown()));
|
|
4718
|
+
checks.push(dockerShutdownCheck(probes.dockerShutdown(local?.dockerContext ?? null)));
|
|
4679
4719
|
}
|
|
4680
4720
|
return checks;
|
|
4681
4721
|
};
|
|
@@ -4695,13 +4735,13 @@ var paintMark = (state, mark) => {
|
|
|
4695
4735
|
const code = state === "ok" ? "32" : state === "todo" ? "33" : "31";
|
|
4696
4736
|
return `\x1B[${code}m${mark}\x1B[0m`;
|
|
4697
4737
|
};
|
|
4698
|
-
var doctorCommand = async (config, localCredential2, claudeGrant2,
|
|
4738
|
+
var doctorCommand = async (config, localCredential2, claudeGrant2, localServer) => {
|
|
4699
4739
|
const checks = await runChecks(config, {
|
|
4700
4740
|
localCredential: localCredential2,
|
|
4701
4741
|
claudeGrant: claudeGrant2,
|
|
4702
4742
|
onPath,
|
|
4703
4743
|
dockerShutdown: observeHostShutdownTimeout,
|
|
4704
|
-
...
|
|
4744
|
+
...localServer === void 0 ? {} : { localServer }
|
|
4705
4745
|
});
|
|
4706
4746
|
for (const check of checks) {
|
|
4707
4747
|
process.stdout.write(`${redactCredentials(formatCheck(check, paintMark))}
|
|
@@ -4753,44 +4793,44 @@ var DOTFILE_CANDIDATES = [
|
|
|
4753
4793
|
}
|
|
4754
4794
|
];
|
|
4755
4795
|
var MAX_FILE_BYTES = 1024 * 1024;
|
|
4756
|
-
var statFile = (home,
|
|
4796
|
+
var statFile = (home, relative6) => {
|
|
4757
4797
|
try {
|
|
4758
|
-
const stat = fs10.statSync(path10.join(home,
|
|
4798
|
+
const stat = fs10.statSync(path10.join(home, relative6));
|
|
4759
4799
|
return stat.isFile() ? stat : null;
|
|
4760
4800
|
} catch {
|
|
4761
4801
|
return null;
|
|
4762
4802
|
}
|
|
4763
4803
|
};
|
|
4764
4804
|
var scanDotfileCandidates = (home) => DOTFILE_CANDIDATES.flatMap(
|
|
4765
|
-
({ group, paths }) => paths.flatMap((
|
|
4766
|
-
const stat = statFile(home,
|
|
4767
|
-
return stat === null ? [] : [{ path:
|
|
4805
|
+
({ group, paths }) => paths.flatMap((relative6) => {
|
|
4806
|
+
const stat = statFile(home, relative6);
|
|
4807
|
+
return stat === null ? [] : [{ path: relative6, group, bytes: stat.size }];
|
|
4768
4808
|
})
|
|
4769
4809
|
);
|
|
4770
4810
|
var homeRelativePath = (home, requested) => {
|
|
4771
|
-
const
|
|
4772
|
-
const outside =
|
|
4773
|
-
return outside ? null :
|
|
4811
|
+
const relative6 = path10.relative(home, path10.resolve(home, requested));
|
|
4812
|
+
const outside = relative6 === "" || relative6 === ".." || relative6.startsWith(`..${path10.sep}`) || path10.isAbsolute(relative6);
|
|
4813
|
+
return outside ? null : relative6.split(path10.sep).join("/");
|
|
4774
4814
|
};
|
|
4775
4815
|
var readSyncFiles = (home, paths_) => {
|
|
4776
4816
|
const files = [];
|
|
4777
4817
|
for (const requested of paths_) {
|
|
4778
|
-
const
|
|
4779
|
-
if (
|
|
4818
|
+
const relative6 = homeRelativePath(home, requested);
|
|
4819
|
+
if (relative6 === null) {
|
|
4780
4820
|
return {
|
|
4781
4821
|
error: `${requested} is not under ${home} \u2014 only files in your home directory sync`
|
|
4782
4822
|
};
|
|
4783
4823
|
}
|
|
4784
|
-
const stat = statFile(home,
|
|
4824
|
+
const stat = statFile(home, relative6);
|
|
4785
4825
|
if (stat === null) {
|
|
4786
|
-
return { error: `${
|
|
4826
|
+
return { error: `${relative6} is not a file under ${home}` };
|
|
4787
4827
|
}
|
|
4788
4828
|
if (stat.size > MAX_FILE_BYTES) {
|
|
4789
|
-
return { error: `${
|
|
4829
|
+
return { error: `${relative6} is over 1MB \u2014 dotfiles are text; trim the selection` };
|
|
4790
4830
|
}
|
|
4791
4831
|
files.push({
|
|
4792
|
-
path:
|
|
4793
|
-
contentsBase64: fs10.readFileSync(path10.join(home,
|
|
4832
|
+
path: relative6,
|
|
4833
|
+
contentsBase64: fs10.readFileSync(path10.join(home, relative6)).toString("base64"),
|
|
4794
4834
|
// eslint-disable-next-line no-bitwise -- permission bits are the point
|
|
4795
4835
|
mode: (stat.mode & 511).toString(8)
|
|
4796
4836
|
});
|
|
@@ -5860,10 +5900,10 @@ var SKIPPED_DIRECTORIES = /* @__PURE__ */ new Set([".git", "node_modules"]);
|
|
|
5860
5900
|
var scanFolder = (dir) => {
|
|
5861
5901
|
const files = [];
|
|
5862
5902
|
const skipped = [];
|
|
5863
|
-
const walk3 = (
|
|
5864
|
-
const entries = fs12.readdirSync(path12.join(dir,
|
|
5903
|
+
const walk3 = (relative6) => {
|
|
5904
|
+
const entries = fs12.readdirSync(path12.join(dir, relative6), { withFileTypes: true }).toSorted((a, b) => a.name.localeCompare(b.name));
|
|
5865
5905
|
for (const entry of entries) {
|
|
5866
|
-
const child =
|
|
5906
|
+
const child = relative6 === "" ? entry.name : `${relative6}/${entry.name}`;
|
|
5867
5907
|
if (entry.isSymbolicLink()) {
|
|
5868
5908
|
skipped.push({ path: child, reason: "symlink" });
|
|
5869
5909
|
} else if (entry.isDirectory()) {
|
|
@@ -6809,8 +6849,8 @@ var pickServiceAttempt = (services, needle, sessionId) => {
|
|
|
6809
6849
|
import * as path14 from "node:path";
|
|
6810
6850
|
var secretFilePathOf = (input, home) => {
|
|
6811
6851
|
const trimmed = input.trim();
|
|
6812
|
-
let
|
|
6813
|
-
if (trimmed === "~" || trimmed.startsWith("~/"))
|
|
6852
|
+
let relative6 = trimmed;
|
|
6853
|
+
if (trimmed === "~" || trimmed.startsWith("~/")) relative6 = trimmed.slice(2);
|
|
6814
6854
|
else if (path14.isAbsolute(trimmed)) {
|
|
6815
6855
|
const fromHome = path14.relative(home, trimmed);
|
|
6816
6856
|
if (fromHome === "" || fromHome.startsWith("..") || path14.isAbsolute(fromHome)) {
|
|
@@ -6819,9 +6859,9 @@ var secretFilePathOf = (input, home) => {
|
|
|
6819
6859
|
issue: `${trimmed} is outside your home directory; name the path under the workspace home, as .aws/credentials`
|
|
6820
6860
|
};
|
|
6821
6861
|
}
|
|
6822
|
-
|
|
6862
|
+
relative6 = fromHome;
|
|
6823
6863
|
}
|
|
6824
|
-
const normalized = path14.posix.normalize(
|
|
6864
|
+
const normalized = path14.posix.normalize(relative6).replace(/^(\.\/)+/, "").replace(/\/$/, "");
|
|
6825
6865
|
const issue = validateSecretFilePath(normalized === "." ? "" : normalized);
|
|
6826
6866
|
return issue === null ? { path: normalized, issue: null } : { path: null, issue };
|
|
6827
6867
|
};
|
|
@@ -6971,6 +7011,27 @@ var describeOwner = (lockDir) => {
|
|
|
6971
7011
|
var lockGuidance = (lockDir) => new ServerStoreError(
|
|
6972
7012
|
`Server is busy: ${lockDir} is locked (${describeOwner(lockDir)}). Wait for the owning command. Never remove a live lock. For stale-lock recovery, verify on that host that the owner and its Docker Compose children have stopped, then move only this lock directory aside and retry. Keep identity.env, active, and generations intact.`
|
|
6973
7013
|
);
|
|
7014
|
+
var heldLocks = /* @__PURE__ */ new Set();
|
|
7015
|
+
var afterRelease = [];
|
|
7016
|
+
var noteReleased = (lock) => {
|
|
7017
|
+
heldLocks.delete(lock);
|
|
7018
|
+
if (heldLocks.size > 0) return;
|
|
7019
|
+
const waiting = afterRelease;
|
|
7020
|
+
afterRelease = [];
|
|
7021
|
+
for (const callback of waiting) callback();
|
|
7022
|
+
};
|
|
7023
|
+
var whenServerLockReleased = (callback) => {
|
|
7024
|
+
if (heldLocks.size === 0) callback();
|
|
7025
|
+
else afterRelease.push(callback);
|
|
7026
|
+
};
|
|
7027
|
+
var releaseOnExit = false;
|
|
7028
|
+
var releaseHeldLocksOnExit = () => {
|
|
7029
|
+
if (releaseOnExit) return;
|
|
7030
|
+
releaseOnExit = true;
|
|
7031
|
+
process.on("exit", () => {
|
|
7032
|
+
for (const lock of heldLocks) lock.release();
|
|
7033
|
+
});
|
|
7034
|
+
};
|
|
6974
7035
|
var acquireLock = (configDir, create) => {
|
|
6975
7036
|
if (create) {
|
|
6976
7037
|
fs14.mkdirSync(configDir, { recursive: true, mode: 448 });
|
|
@@ -7005,7 +7066,7 @@ var acquireLock = (configDir, create) => {
|
|
|
7005
7066
|
} catch {
|
|
7006
7067
|
throw lockGuidance(lockDir);
|
|
7007
7068
|
}
|
|
7008
|
-
|
|
7069
|
+
const lock = {
|
|
7009
7070
|
assertOwned,
|
|
7010
7071
|
release: () => {
|
|
7011
7072
|
const result = attempt(() => {
|
|
@@ -7014,9 +7075,13 @@ var acquireLock = (configDir, create) => {
|
|
|
7014
7075
|
fs14.rmdirSync(lockDir);
|
|
7015
7076
|
});
|
|
7016
7077
|
open = false;
|
|
7078
|
+
noteReleased(lock);
|
|
7017
7079
|
return result;
|
|
7018
7080
|
}
|
|
7019
7081
|
};
|
|
7082
|
+
heldLocks.add(lock);
|
|
7083
|
+
releaseHeldLocksOnExit();
|
|
7084
|
+
return lock;
|
|
7020
7085
|
};
|
|
7021
7086
|
var readIdentity = (paths) => {
|
|
7022
7087
|
const identity = readOptional(paths.identity);
|
|
@@ -7092,8 +7157,8 @@ var prepareGeneration = (paths, files) => {
|
|
|
7092
7157
|
return { directory, files };
|
|
7093
7158
|
};
|
|
7094
7159
|
var activateGeneration = (paths, generation) => {
|
|
7095
|
-
const
|
|
7096
|
-
if (!/^generations\/gen-[0-9a-f-]{36}$/.test(
|
|
7160
|
+
const relative6 = path15.relative(paths.configDir, generation.directory);
|
|
7161
|
+
if (!/^generations\/gen-[0-9a-f-]{36}$/.test(relative6) || readIdentity(paths) !== fs14.readFileSync(path15.join(generation.directory, "identity.env"), "utf8")) {
|
|
7097
7162
|
throw new ServerStoreError("Cannot activate a generation outside this installation identity.");
|
|
7098
7163
|
}
|
|
7099
7164
|
for (const [key, content] of allFiles(generation.files)) {
|
|
@@ -7102,7 +7167,7 @@ var activateGeneration = (paths, generation) => {
|
|
|
7102
7167
|
}
|
|
7103
7168
|
}
|
|
7104
7169
|
const pointer = path15.join(paths.configDir, `.active-${randomUUID2()}`);
|
|
7105
|
-
fs14.symlinkSync(
|
|
7170
|
+
fs14.symlinkSync(relative6, pointer);
|
|
7106
7171
|
fs14.renameSync(pointer, paths.active);
|
|
7107
7172
|
syncDirectory(paths.configDir);
|
|
7108
7173
|
};
|
|
@@ -8190,7 +8255,8 @@ var askSsh = async (asked, settings, publishedBefore = sshAt(settings)) => {
|
|
|
8190
8255
|
value: at
|
|
8191
8256
|
}
|
|
8192
8257
|
];
|
|
8193
|
-
const
|
|
8258
|
+
const stated = settings.declared.includes("workspace-ssh");
|
|
8259
|
+
const current = isLoopbackAddress(at) || settings.exposure === "public" && !stated ? 0 : choices.findIndex((choice) => choice.value === at);
|
|
8194
8260
|
const chosen = await choose(
|
|
8195
8261
|
io,
|
|
8196
8262
|
`Should VS Code Remote-SSH and mend ssh reach sessions from other machines?${settings.edgeHost === void 0 ? " Workspace SSH" : " The edge carries HTTPS only; workspace SSH"} is a port of its own.`,
|
|
@@ -8204,7 +8270,7 @@ var askSsh = async (asked, settings, publishedBefore = sshAt(settings)) => {
|
|
|
8204
8270
|
});
|
|
8205
8271
|
if (isLoopbackAddress(chosen)) return onLoopback();
|
|
8206
8272
|
if (settings.exposure !== "public") return settled({ ...settings, sshBind: chosen });
|
|
8207
|
-
const declared =
|
|
8273
|
+
const declared = stated && at === chosen;
|
|
8208
8274
|
const checked = await choose(
|
|
8209
8275
|
io,
|
|
8210
8276
|
`Mend cannot see who reaches ${publishedAddress(chosen, port)} from outside, and a public server does not start until you state that you checked (the exposure gate's workspace-ssh item).`,
|
|
@@ -8438,8 +8504,14 @@ var askOrigins = async (asked, settings) => {
|
|
|
8438
8504
|
var walk2 = async (asked, settings) => {
|
|
8439
8505
|
let next = await askReach(asked, settings);
|
|
8440
8506
|
next = await askT3(asked, next);
|
|
8441
|
-
if (next.exposure === "public"
|
|
8442
|
-
|
|
8507
|
+
if (next.exposure === "public") {
|
|
8508
|
+
asked.io.write("");
|
|
8509
|
+
asked.io.write(
|
|
8510
|
+
"The public exposure gate has items Mend cannot observe from inside; each stays open until you state you checked it from outside. You can state them now, or later with mend server setup --declare."
|
|
8511
|
+
);
|
|
8512
|
+
if (await yesNo(asked.io, "State what you have checked from outside the network now?", false))
|
|
8513
|
+
next = await askDeclarations(asked, next);
|
|
8514
|
+
}
|
|
8443
8515
|
next = await askMirrors(asked, next, true);
|
|
8444
8516
|
return askTenancy(asked, next);
|
|
8445
8517
|
};
|
|
@@ -8483,6 +8555,61 @@ var changeOne = async (asked, settings) => {
|
|
|
8483
8555
|
if (!await yesNo(asked.io, "Change something else?", false)) return next;
|
|
8484
8556
|
}
|
|
8485
8557
|
};
|
|
8558
|
+
var portOf = (input) => {
|
|
8559
|
+
if (!/^\d+$/.test(input)) return null;
|
|
8560
|
+
const port = Number(input);
|
|
8561
|
+
return port >= 1 && port <= 65535 ? port : null;
|
|
8562
|
+
};
|
|
8563
|
+
var withAppPort = (settings, port) => {
|
|
8564
|
+
const url = new URL(settings.appUrl);
|
|
8565
|
+
if (settings.edgeHost === void 0 && url.port === String(settings.appPort))
|
|
8566
|
+
url.port = String(port);
|
|
8567
|
+
return { ...settings, appPort: port, appUrl: url.origin };
|
|
8568
|
+
};
|
|
8569
|
+
var settlePorts = async (asked, settings) => {
|
|
8570
|
+
const { io, context } = asked;
|
|
8571
|
+
const ours = (port) => context.saved !== null && (context.saved.appPort === port || context.saved.sshPort === port);
|
|
8572
|
+
let next = settings;
|
|
8573
|
+
for (const what of ["web", "ssh"]) {
|
|
8574
|
+
const port = what === "web" ? next.appPort : next.sshPort;
|
|
8575
|
+
const other = what === "web" ? next.sshPort : next.appPort;
|
|
8576
|
+
const address = what === "web" ? next.bind : next.sshBind ?? next.bind;
|
|
8577
|
+
if (ours(port)) continue;
|
|
8578
|
+
const holder = await context.observe.portHolder(address, port, what);
|
|
8579
|
+
if (holder === null) continue;
|
|
8580
|
+
io.write("");
|
|
8581
|
+
io.write(`Observed: ${publishedAddress(address, port)} is taken: ${holder}.`);
|
|
8582
|
+
const usable = async (candidate) => candidate !== other && candidate !== next.t3GatewayPort && (ours(candidate) || !await context.observe.portTaken(candidate, address));
|
|
8583
|
+
let free;
|
|
8584
|
+
for (let candidate = port + 1; candidate <= Math.min(port + 100, 65535); candidate += 1)
|
|
8585
|
+
if (await usable(candidate)) {
|
|
8586
|
+
free = candidate;
|
|
8587
|
+
break;
|
|
8588
|
+
}
|
|
8589
|
+
let picked;
|
|
8590
|
+
while (picked === void 0) {
|
|
8591
|
+
const answered = await typed(
|
|
8592
|
+
io,
|
|
8593
|
+
what === "web" ? "Mend's web port" : "The workspace SSH port",
|
|
8594
|
+
free === void 0 ? void 0 : String(free),
|
|
8595
|
+
(input) => {
|
|
8596
|
+
const parsed = portOf(input);
|
|
8597
|
+
if (parsed === null) return { refused: "A port is a whole number from 1 to 65535." };
|
|
8598
|
+
if (parsed === other)
|
|
8599
|
+
return { refused: `${parsed} is the ${what === "web" ? "SSH" : "web"} port.` };
|
|
8600
|
+
if (parsed === next.t3GatewayPort)
|
|
8601
|
+
return { refused: `${parsed} is the T3 Code gateway's port.` };
|
|
8602
|
+
return { value: parsed };
|
|
8603
|
+
}
|
|
8604
|
+
);
|
|
8605
|
+
const taken = ours(answered) ? null : await context.observe.portHolder(address, answered, what);
|
|
8606
|
+
if (taken === null) picked = answered;
|
|
8607
|
+
else io.write(` ${publishedAddress(address, answered)} is taken too: ${taken}.`);
|
|
8608
|
+
}
|
|
8609
|
+
next = what === "web" ? withAppPort(next, picked) : { ...next, sshPort: picked };
|
|
8610
|
+
}
|
|
8611
|
+
return next;
|
|
8612
|
+
};
|
|
8486
8613
|
var runGuide = async (io, context) => {
|
|
8487
8614
|
const base = context.saved ?? context.defaults;
|
|
8488
8615
|
const asked = {
|
|
@@ -8516,7 +8643,7 @@ var runGuide = async (io, context) => {
|
|
|
8516
8643
|
);
|
|
8517
8644
|
target = how === "keep" ? base : how === "change" ? await changeOne(asked, base) : await walk2(asked, base);
|
|
8518
8645
|
}
|
|
8519
|
-
target = settled(target);
|
|
8646
|
+
target = await settlePorts(asked, settled(target));
|
|
8520
8647
|
const flags = flagsFor(base, target);
|
|
8521
8648
|
let resolved;
|
|
8522
8649
|
try {
|
|
@@ -8868,6 +8995,16 @@ var parseSetupOptions = (args) => {
|
|
|
8868
8995
|
};
|
|
8869
8996
|
};
|
|
8870
8997
|
var HOST_FLAGS = /* @__PURE__ */ new Set(["--allow-userns", "--no-allow-userns"]);
|
|
8998
|
+
var ENGINE_FLAGS = /* @__PURE__ */ new Set(["--context", "--docker-socket"]);
|
|
8999
|
+
var answersNoQuestion = (args) => {
|
|
9000
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
9001
|
+
const arg = args[index] ?? "";
|
|
9002
|
+
if (HOST_FLAGS.has(arg)) continue;
|
|
9003
|
+
if (!ENGINE_FLAGS.has(arg)) return false;
|
|
9004
|
+
index += 1;
|
|
9005
|
+
}
|
|
9006
|
+
return true;
|
|
9007
|
+
};
|
|
8871
9008
|
var resolveMirrors = (saved, options) => {
|
|
8872
9009
|
const base = saved ?? DEFAULT_MIRRORS;
|
|
8873
9010
|
const npmOn = options.npmMirror ?? (options.npmMirrorMaxSize !== void 0 || base.npm !== null);
|
|
@@ -9809,6 +9946,25 @@ var envKeyNames = (env) => env.split("\n").flatMap((line) => {
|
|
|
9809
9946
|
const match = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)=/.exec(line);
|
|
9810
9947
|
return match?.[1] === void 0 ? [] : [match[1]];
|
|
9811
9948
|
});
|
|
9949
|
+
var readLocalServer = async (configDir) => {
|
|
9950
|
+
const result = await withServerStore(
|
|
9951
|
+
configDir,
|
|
9952
|
+
async (store) => {
|
|
9953
|
+
const installation = storeValue(readServerInstallation(store));
|
|
9954
|
+
const identity = storeValue(store.readIdentity());
|
|
9955
|
+
if (installation === null || identity === null) return null;
|
|
9956
|
+
return {
|
|
9957
|
+
url: installation.config.appUrl,
|
|
9958
|
+
dockerContext: installation.config.dockerContext,
|
|
9959
|
+
version: installation.config.serverVersion,
|
|
9960
|
+
instance: instanceIdOf(parseSecrets(identity).betterAuthSecret)
|
|
9961
|
+
};
|
|
9962
|
+
},
|
|
9963
|
+
{ create: false }
|
|
9964
|
+
);
|
|
9965
|
+
if (result._tag === "error") throw result.error;
|
|
9966
|
+
return result.value;
|
|
9967
|
+
};
|
|
9812
9968
|
var readServerInstallationFacts = async (configDir) => {
|
|
9813
9969
|
const result = await withServerStore(
|
|
9814
9970
|
configDir,
|
|
@@ -9875,25 +10031,86 @@ var observeT3Gateway = async (runtime, port) => {
|
|
|
9875
10031
|
}
|
|
9876
10032
|
return `The t3code gateway did not answer at 127.0.0.1:${port} from this machine within about a minute. Mend runs without it; mend server logs shows what it said, and mend server status looks again.`;
|
|
9877
10033
|
};
|
|
9878
|
-
var
|
|
9879
|
-
|
|
10034
|
+
var instanceIdOf = (betterAuthSecret) => createHmac("sha256", betterAuthSecret).update("mend instance id").digest("hex").slice(0, 32);
|
|
10035
|
+
var readHealth = (response) => {
|
|
10036
|
+
if (response.error !== void 0) return { kind: "other", failure: response.error };
|
|
10037
|
+
if (response.status < 200 || response.status >= 300)
|
|
10038
|
+
return { kind: "other", failure: `HTTP ${response.status}` };
|
|
10039
|
+
let fields;
|
|
10040
|
+
try {
|
|
10041
|
+
fields = ownFields(JSON.parse(response.body));
|
|
10042
|
+
} catch {
|
|
10043
|
+
return { kind: "other", failure: "health response is not valid JSON" };
|
|
10044
|
+
}
|
|
10045
|
+
const version = fields?.get("version");
|
|
10046
|
+
const instance = fields?.get("instance");
|
|
10047
|
+
if (fields === null || typeof version !== "string")
|
|
10048
|
+
return { kind: "other", failure: "health response names no Mend version" };
|
|
10049
|
+
return {
|
|
10050
|
+
kind: "mend",
|
|
10051
|
+
ok: fields.get("status") === "ok",
|
|
10052
|
+
version,
|
|
10053
|
+
instance: typeof instance === "string" ? instance : void 0
|
|
10054
|
+
};
|
|
10055
|
+
};
|
|
10056
|
+
var isThisInstall = (answer2, version, instance) => answer2.kind === "mend" && answer2.ok && answer2.version === version && (answer2.instance === void 0 || answer2.instance === instance);
|
|
10057
|
+
var connectHost = (address) => address === "0.0.0.0" ? "127.0.0.1" : address === "::" ? "::1" : address;
|
|
10058
|
+
var portHolder = async (runtime, address, port, what) => {
|
|
10059
|
+
if (runtime.portTaken === void 0 || !await runtime.portTaken(port, address)) return null;
|
|
10060
|
+
if (what === "ssh") return "something else listens there";
|
|
10061
|
+
const host = connectHost(address);
|
|
10062
|
+
const answer2 = readHealth(
|
|
10063
|
+
await runtime.fetchText(
|
|
10064
|
+
`http://${net4.isIPv6(host) ? `[${host}]` : host}:${port}/api/health`,
|
|
10065
|
+
2e3
|
|
10066
|
+
)
|
|
10067
|
+
);
|
|
10068
|
+
return answer2.kind === "mend" ? `another Mend, ${answer2.version}, answers there` : "something else listens there";
|
|
10069
|
+
};
|
|
10070
|
+
var refuseTakenPorts = async (runtime, wanted, existing) => {
|
|
10071
|
+
const ours = (port) => existing !== null && (existing.appPort === port || existing.sshPort === port);
|
|
10072
|
+
const taken = [];
|
|
10073
|
+
const flags = [];
|
|
10074
|
+
for (const [what, address, port, flag, name] of [
|
|
10075
|
+
["web", wanted.bind, wanted.appPort, "--port <n>", "Mend's web port"],
|
|
10076
|
+
["ssh", wanted.sshBind ?? wanted.bind, wanted.sshPort, "--ssh-port <n>", "workspace SSH"]
|
|
10077
|
+
]) {
|
|
10078
|
+
if (ours(port)) continue;
|
|
10079
|
+
const holder = await portHolder(runtime, address, port, what);
|
|
10080
|
+
if (holder === null) continue;
|
|
10081
|
+
taken.push(`${publishedAddress(address, port)}, ${name}, is taken: ${holder}.`);
|
|
10082
|
+
flags.push(flag);
|
|
10083
|
+
}
|
|
10084
|
+
if (taken.length === 0) return;
|
|
10085
|
+
throw setupError(
|
|
10086
|
+
`${taken.join(" ")} Setup changed nothing. Choose ${flags.length === 1 ? "another port" : "other ports"} with ${flags.join(" ")}, or stop what holds ${flags.length === 1 ? "it" : "them"}, then run mend server setup again.`
|
|
10087
|
+
);
|
|
10088
|
+
};
|
|
10089
|
+
var probeHealth = async (runtime, config, instance) => {
|
|
10090
|
+
const healthUrl = `${healthOrigin(config)}/api/health`;
|
|
10091
|
+
const expectedVersion = config.serverVersion;
|
|
9880
10092
|
let lastFailure = "request did not complete";
|
|
10093
|
+
let other;
|
|
9881
10094
|
for (let attempt2 = 0; attempt2 < 30; attempt2 += 1) {
|
|
9882
|
-
const
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
}
|
|
10095
|
+
const answer2 = readHealth(await runtime.fetchText(healthUrl, 2e3));
|
|
10096
|
+
if (isThisInstall(answer2, expectedVersion, instance)) return;
|
|
10097
|
+
other = void 0;
|
|
10098
|
+
if (answer2.kind === "other") lastFailure = answer2.failure;
|
|
10099
|
+
else if (answer2.ok && answer2.instance !== void 0 && answer2.instance !== instance) {
|
|
10100
|
+
other = answer2;
|
|
10101
|
+
lastFailure = `another Mend install, ${answer2.version}, answers there`;
|
|
10102
|
+
} else if (answer2.ok && answer2.version !== expectedVersion) {
|
|
10103
|
+
other = answer2;
|
|
10104
|
+
lastFailure = `Mend ${answer2.version} answers there, not ${expectedVersion}`;
|
|
10105
|
+
} else lastFailure = `health response must report status ok and version ${expectedVersion}`;
|
|
9894
10106
|
if (attempt2 % 10 === 0) runtime.writeLine(`Waiting for ${healthUrl} (${lastFailure})`);
|
|
9895
10107
|
if (attempt2 < 29) await runtime.sleep(2e3);
|
|
9896
10108
|
}
|
|
10109
|
+
if (other !== void 0) {
|
|
10110
|
+
throw setupError(
|
|
10111
|
+
`Mend started, but ${healthUrl} is not the Mend setup just started: ${lastFailure}. When another server holds port ${config.appPort} on this machine (another Docker engine, an older install), Docker cannot publish this one there. Choose another port with --port <n>, or stop what holds it, then run mend server setup again.`
|
|
10112
|
+
);
|
|
10113
|
+
}
|
|
9897
10114
|
throw setupError(
|
|
9898
10115
|
`Mend started, but ${healthUrl} did not answer successfully (${lastFailure}). Check the Mend container logs in Docker, then retry mend server setup.`
|
|
9899
10116
|
);
|
|
@@ -10296,7 +10513,7 @@ var mirrorsChangedLines = (before, config) => {
|
|
|
10296
10513
|
);
|
|
10297
10514
|
return lines;
|
|
10298
10515
|
};
|
|
10299
|
-
var UNASKED_FRESH_SETUP = "No terminal to ask on and no
|
|
10516
|
+
var UNASKED_FRESH_SETUP = "No terminal to ask on, and no flag says how this Mend is reached (--context and --docker-socket only choose the Docker engine), so setup does not guess. Run mend server setup in a terminal to answer its questions, or say it with flags: --yes takes the defaults (this machine only, http://localhost:3105); --bind <address> --url <origin> serves a private network (a tailnet, a LAN, a VPN); for public HTTPS, set up on this machine first, create the first account, then run mend server setup --edge <host> --exposure public. mend help server setup lists every flag.";
|
|
10300
10517
|
var refuseLegacyContract = (existing) => {
|
|
10301
10518
|
if (existing !== null && existing.config.assetContract !== ASSET_CONTRACT) {
|
|
10302
10519
|
throw setupError(
|
|
@@ -10315,7 +10532,8 @@ var guideObservations = (runtime) => ({
|
|
|
10315
10532
|
},
|
|
10316
10533
|
lookupHost: runtime.lookupHost ?? (async () => null),
|
|
10317
10534
|
localAddresses: runtime.localAddresses ?? (() => []),
|
|
10318
|
-
portTaken: runtime.portTaken ?? (async () => false)
|
|
10535
|
+
portTaken: runtime.portTaken ?? (async () => false),
|
|
10536
|
+
portHolder: (address, port, what) => portHolder(runtime, address, port, what)
|
|
10319
10537
|
});
|
|
10320
10538
|
var guidedSetup = async (runtime, prompter, hostFlags2 = []) => {
|
|
10321
10539
|
if (runtime.platform !== "linux" && runtime.platform !== "darwin") {
|
|
@@ -10379,7 +10597,7 @@ var setupServer = async (args, runtime, store, run2 = {}) => {
|
|
|
10379
10597
|
"The install changed while you answered: another mend server setup or upgrade ran. This one changed nothing; run mend server setup again to see the install as it is now."
|
|
10380
10598
|
);
|
|
10381
10599
|
}
|
|
10382
|
-
if (run2.askedAgainst === void 0 && args
|
|
10600
|
+
if (run2.askedAgainst === void 0 && answersNoQuestion(args) && existing === null) {
|
|
10383
10601
|
throw setupError(UNASKED_FRESH_SETUP);
|
|
10384
10602
|
}
|
|
10385
10603
|
const savedIdentity = storeValue(store.readIdentity());
|
|
@@ -10390,12 +10608,26 @@ var setupServer = async (args, runtime, store, run2 = {}) => {
|
|
|
10390
10608
|
);
|
|
10391
10609
|
}
|
|
10392
10610
|
refuseLegacyContract(existing);
|
|
10611
|
+
const variable = runtime.dockerContextVariable;
|
|
10612
|
+
const fromVariable = options.context === void 0 && existing === null && variable !== void 0;
|
|
10393
10613
|
const selectedContext = await selectDockerContext(
|
|
10394
10614
|
runtime,
|
|
10395
|
-
options.context ?? existing?.config.dockerContext
|
|
10615
|
+
options.context ?? (fromVariable ? variable : existing?.config.dockerContext)
|
|
10396
10616
|
);
|
|
10397
10617
|
const operatingSystem = await checkDocker(runtime, selectedContext.name);
|
|
10398
|
-
runtime.writeLine(
|
|
10618
|
+
runtime.writeLine(
|
|
10619
|
+
`Using Docker context "${selectedContext.name}" (${selectedContext.endpoint})${fromVariable ? ", from DOCKER_CONTEXT" : ""}`
|
|
10620
|
+
);
|
|
10621
|
+
if (existing !== null && options.context === void 0 && variable !== void 0 && variable !== existing.config.dockerContext) {
|
|
10622
|
+
runtime.writeLine(
|
|
10623
|
+
`DOCKER_CONTEXT is "${variable}"; this install runs on Docker context "${existing.config.dockerContext}", where its data is, and stays there. --context moves it.`
|
|
10624
|
+
);
|
|
10625
|
+
}
|
|
10626
|
+
await refuseTakenPorts(
|
|
10627
|
+
runtime,
|
|
10628
|
+
validateExposure(existing?.config ?? null, options),
|
|
10629
|
+
existing?.config ?? null
|
|
10630
|
+
);
|
|
10399
10631
|
const userNamespaces = await settleHostUserNamespaces(runtime, options, selectedContext.name);
|
|
10400
10632
|
const serverVersion = await resolveServerVersion(runtime, options, existing?.config ?? null);
|
|
10401
10633
|
const mirrors = resolveMirrors(existing?.config.mirrors, options);
|
|
@@ -10425,7 +10657,9 @@ var setupServer = async (args, runtime, store, run2 = {}) => {
|
|
|
10425
10657
|
"{{json .}}"
|
|
10426
10658
|
]);
|
|
10427
10659
|
const line = dockerShutdownSetupLine(
|
|
10428
|
-
readShutdownTimeout(
|
|
10660
|
+
readShutdownTimeout(
|
|
10661
|
+
runtime.dockerDaemonFacts(info.status === 0 ? info.stdout : null, selectedContext.name)
|
|
10662
|
+
)
|
|
10429
10663
|
);
|
|
10430
10664
|
if (line !== null) runtime.writeLine(line);
|
|
10431
10665
|
}
|
|
@@ -10482,7 +10716,8 @@ var setupServer = async (args, runtime, store, run2 = {}) => {
|
|
|
10482
10716
|
storeValue(store.activate(generation));
|
|
10483
10717
|
await startCompose(runtime, installation);
|
|
10484
10718
|
await initGarage(runtime, installation, secrets);
|
|
10485
|
-
|
|
10719
|
+
const instance = instanceIdOf(secrets.betterAuthSecret);
|
|
10720
|
+
await probeHealth(runtime, config, instance);
|
|
10486
10721
|
runtime.writeLine(reachableLine(config));
|
|
10487
10722
|
const edgeStarted = edgeStartedLine(config);
|
|
10488
10723
|
if (edgeStarted !== null) runtime.writeLine(edgeStarted);
|
|
@@ -10503,14 +10738,14 @@ var setupServer = async (args, runtime, store, run2 = {}) => {
|
|
|
10503
10738
|
}
|
|
10504
10739
|
for (const line of mirrorsChangedLines(existing?.config.mirrors, config)) runtime.writeLine(line);
|
|
10505
10740
|
const urlChanged = existing !== null && existing.config.appUrl !== config.appUrl;
|
|
10506
|
-
const cliHere = urlChanged ? await followUrlChange(runtime, options, existing.config, config) :
|
|
10741
|
+
const cliHere = urlChanged ? await followUrlChange(runtime, options, existing.config, config, instance) : await offerCliHere(runtime, options, existing?.config ?? null, config, instance);
|
|
10507
10742
|
const users = await instanceUsers(runtime, healthOrigin(config));
|
|
10508
10743
|
if (users === "none" || users === null && existing === null) {
|
|
10509
10744
|
runtime.writeLine(
|
|
10510
10745
|
`Open ${config.appUrl}, create the first account, then run: mend login --url ${config.appUrl}`
|
|
10511
10746
|
);
|
|
10512
10747
|
} else if (urlChanged) {
|
|
10513
|
-
} else if (cliHere === null || !cliHere.signedIn || !await answersAs(runtime, cliHere.url, config.serverVersion)) {
|
|
10748
|
+
} else if (cliHere === null || !cliHere.signedIn || !await answersAs(runtime, cliHere.url, config.serverVersion, instance)) {
|
|
10514
10749
|
runtime.writeLine(
|
|
10515
10750
|
`Open ${config.appUrl} to sign in. To sign in this machine's CLI, run: mend login --url ${config.appUrl}`
|
|
10516
10751
|
);
|
|
@@ -10527,15 +10762,35 @@ var instanceUsers = async (runtime, origin) => {
|
|
|
10527
10762
|
return null;
|
|
10528
10763
|
}
|
|
10529
10764
|
};
|
|
10530
|
-
var answersAs = async (runtime, url, version) =>
|
|
10531
|
-
|
|
10532
|
-
|
|
10533
|
-
|
|
10534
|
-
|
|
10535
|
-
|
|
10536
|
-
|
|
10537
|
-
|
|
10765
|
+
var answersAs = async (runtime, url, version, instance) => isThisInstall(await healthAt(runtime, url), version, instance);
|
|
10766
|
+
var healthAt = async (runtime, url) => readHealth(await runtime.fetchText(`${url.replace(/\/+$/, "")}/api/health`, 3e3));
|
|
10767
|
+
var DEFAULT_CLI_URL = `http://localhost:${DEFAULT_APP_PORT}`;
|
|
10768
|
+
var offerCliHere = async (runtime, options, existing, config, instance) => {
|
|
10769
|
+
if (runtime.savedCliLogin === void 0) return null;
|
|
10770
|
+
const saved = runtime.savedCliLogin(runtime.configDir);
|
|
10771
|
+
if (runtime.repointCliLogin === void 0) return saved;
|
|
10772
|
+
const url = saved?.url ?? DEFAULT_CLI_URL;
|
|
10773
|
+
const there = await healthAt(runtime, url);
|
|
10774
|
+
if (isThisInstall(there, config.serverVersion, instance)) return saved;
|
|
10775
|
+
const signedIn = saved?.signedIn === true;
|
|
10776
|
+
const keepSignIn = signedIn && there.kind === "other" && existing !== null;
|
|
10777
|
+
const preferred = !(signedIn && there.kind === "mend");
|
|
10778
|
+
const what = there.kind === "mend" ? `another Mend, ${there.version}, answers` : "nothing answers";
|
|
10779
|
+
const signIn = keepSignIn ? " Its sign-in carries over." : signedIn ? ` Its sign-in at ${url} stays behind.` : "";
|
|
10780
|
+
let move = options.yes && preferred;
|
|
10781
|
+
if (!options.yes && runtime.prompter !== void 0) {
|
|
10782
|
+
const answer2 = await runtime.prompter(
|
|
10783
|
+
`This machine's CLI points at ${url}, where ${what}. Point it at ${config.appUrl}?${signIn} ${preferred ? "[Y/n]" : "[y/N]"} `
|
|
10784
|
+
);
|
|
10785
|
+
const given = answer2?.trim() ?? "";
|
|
10786
|
+
move = answer2 !== null && (given === "" ? preferred : /^y/i.test(given));
|
|
10538
10787
|
}
|
|
10788
|
+
if (!move) return saved;
|
|
10789
|
+
runtime.repointCliLogin(runtime.configDir, config.appUrl, { keepSignIn });
|
|
10790
|
+
runtime.writeLine(
|
|
10791
|
+
`This machine's CLI now points at ${config.appUrl}${keepSignIn ? "; its sign-in carried over" : ""}.`
|
|
10792
|
+
);
|
|
10793
|
+
return { url: config.appUrl, signedIn: keepSignIn };
|
|
10539
10794
|
};
|
|
10540
10795
|
var reachedBefore = (url, before) => {
|
|
10541
10796
|
let parsed;
|
|
@@ -10549,12 +10804,12 @@ var reachedBefore = (url, before) => {
|
|
|
10549
10804
|
const port = parsed.port === "" ? parsed.protocol === "https:" ? 443 : 80 : Number(parsed.port);
|
|
10550
10805
|
return isLoopbackHost(parsed.hostname) && port === before.appPort && (isLoopbackBind(before.bind) || before.bind === "0.0.0.0" || before.bind === "::");
|
|
10551
10806
|
};
|
|
10552
|
-
var followUrlChange = async (runtime, options, before, after) => {
|
|
10807
|
+
var followUrlChange = async (runtime, options, before, after, instance) => {
|
|
10553
10808
|
runtime.writeLine(
|
|
10554
10809
|
`Mend's URL changed from ${before.appUrl} to ${after.appUrl}. Browsers open ${after.appUrl}. A CLI signed in at the old URL (another account on this machine, another machine) moves with: mend login --url ${after.appUrl}`
|
|
10555
10810
|
);
|
|
10556
10811
|
const saved = runtime.savedCliLogin?.(runtime.configDir) ?? null;
|
|
10557
|
-
if (saved === null || !saved.signedIn || !reachedBefore(saved.url, before) || await answersAs(runtime, saved.url, after.serverVersion)) {
|
|
10812
|
+
if (saved === null || !saved.signedIn || !reachedBefore(saved.url, before) || await answersAs(runtime, saved.url, after.serverVersion, instance)) {
|
|
10558
10813
|
return saved;
|
|
10559
10814
|
}
|
|
10560
10815
|
let move = options.yes;
|
|
@@ -10646,7 +10901,7 @@ var startInstallation = async (runtime, installation, secrets) => {
|
|
|
10646
10901
|
"--no-build"
|
|
10647
10902
|
]);
|
|
10648
10903
|
await initGarage(runtime, installation, secrets);
|
|
10649
|
-
await probeHealth(runtime,
|
|
10904
|
+
await probeHealth(runtime, installation.config, instanceIdOf(secrets.betterAuthSecret));
|
|
10650
10905
|
runtime.writeLine(reachableLine(installation.config));
|
|
10651
10906
|
};
|
|
10652
10907
|
var DEFAULT_KEEP_BACKUPS = 2;
|
|
@@ -11326,6 +11581,7 @@ var nodeServerRuntime = () => {
|
|
|
11326
11581
|
repointCliLogin: repointCliLoginHere,
|
|
11327
11582
|
probeSsh: probeSshFromHere,
|
|
11328
11583
|
portTaken: portTakenHere,
|
|
11584
|
+
...environment["DOCKER_CONTEXT"] === void 0 || environment["DOCKER_CONTEXT"].trim() === "" ? {} : { dockerContextVariable: environment["DOCKER_CONTEXT"].trim() },
|
|
11329
11585
|
...process.stdin.isTTY === true && process.stdout.isTTY === true ? { prompter: askOnTerminal } : {},
|
|
11330
11586
|
lookupHost: async (host) => {
|
|
11331
11587
|
try {
|
|
@@ -11334,8 +11590,7 @@ var nodeServerRuntime = () => {
|
|
|
11334
11590
|
return null;
|
|
11335
11591
|
}
|
|
11336
11592
|
},
|
|
11337
|
-
|
|
11338
|
-
localAddresses: () => Object.entries(os10.networkInterfaces()).filter(([name]) => !/^(docker|br-|veth|virbr|cni|flannel|vmnet|vboxnet)/.test(name)).flatMap(([, entries]) => entries ?? []).filter((entry) => !entry.internal).map((entry) => entry.address),
|
|
11593
|
+
localAddresses: () => reachableAddressesOf(os10.networkInterfaces()),
|
|
11339
11594
|
readStdin: async () => {
|
|
11340
11595
|
const chunks = [];
|
|
11341
11596
|
for await (const chunk of process.stdin)
|
|
@@ -11380,11 +11635,33 @@ var sshBannerAt = async (host, port, timeoutMs) => {
|
|
|
11380
11635
|
socket.destroy();
|
|
11381
11636
|
}
|
|
11382
11637
|
};
|
|
11383
|
-
var
|
|
11384
|
-
|
|
11385
|
-
|
|
11386
|
-
|
|
11387
|
-
|
|
11638
|
+
var BRIDGE_INTERFACE = /^(docker|br-|veth|virbr|cni|flannel|vmnet|vboxnet|bridge\d)/;
|
|
11639
|
+
var ipv4Value = (address) => address.split(".").reduce((sum, octet) => sum * 256 + Number(octet), 0);
|
|
11640
|
+
var isNetworkAddress = (entry) => {
|
|
11641
|
+
if (entry.family !== "IPv4") return false;
|
|
11642
|
+
if (entry.address.endsWith(".0")) return true;
|
|
11643
|
+
const prefix = Number(entry.cidr?.split("/")[1] ?? "32");
|
|
11644
|
+
return prefix < 31 && ipv4Value(entry.address) % 2 ** (32 - prefix) === 0;
|
|
11645
|
+
};
|
|
11646
|
+
var reachableAddressesOf = (interfaces) => Object.entries(interfaces).filter(([name]) => !BRIDGE_INTERFACE.test(name)).flatMap(([, entries]) => entries ?? []).filter((entry) => !entry.internal && !isNetworkAddress(entry)).map((entry) => entry.address);
|
|
11647
|
+
var portTakenHere = async (port, address = "127.0.0.1") => {
|
|
11648
|
+
const bindFails = await new Promise((resolve8) => {
|
|
11649
|
+
const server = net4.createServer();
|
|
11650
|
+
server.once("error", (error) => resolve8(error.code === "EADDRINUSE"));
|
|
11651
|
+
server.listen(port, address, () => server.close(() => resolve8(false)));
|
|
11652
|
+
});
|
|
11653
|
+
if (bindFails) return true;
|
|
11654
|
+
return new Promise((resolve8) => {
|
|
11655
|
+
const socket = net4.connect({ host: connectHost(address), port });
|
|
11656
|
+
const done = (answered) => {
|
|
11657
|
+
socket.destroy();
|
|
11658
|
+
resolve8(answered);
|
|
11659
|
+
};
|
|
11660
|
+
socket.setTimeout(1e3, () => done(false));
|
|
11661
|
+
socket.once("connect", () => done(true));
|
|
11662
|
+
socket.once("error", () => done(false));
|
|
11663
|
+
});
|
|
11664
|
+
};
|
|
11388
11665
|
var probeSshFromHere = async (bind, port) => {
|
|
11389
11666
|
const unspecified = bind === "0.0.0.0" || bind === "::";
|
|
11390
11667
|
const addresses = unspecified ? Object.values(os10.networkInterfaces()).flatMap((entries) => entries ?? []).filter(
|
|
@@ -11423,11 +11700,15 @@ var savedCliLoginHere = (configDir) => {
|
|
|
11423
11700
|
const token = fields?.get("token");
|
|
11424
11701
|
return typeof url === "string" ? { url, signedIn: typeof token === "string" && token !== "" } : null;
|
|
11425
11702
|
};
|
|
11426
|
-
var repointCliLoginHere = (configDir, url) => {
|
|
11427
|
-
const fields = cliJsonFields(configDir);
|
|
11428
|
-
if (fields === null) return;
|
|
11703
|
+
var repointCliLoginHere = (configDir, url, options = { keepSignIn: true }) => {
|
|
11429
11704
|
const file = path16.join(configDir, "cli.json");
|
|
11430
|
-
|
|
11705
|
+
const fields = cliJsonFields(configDir) ?? (fs16.existsSync(file) ? null : /* @__PURE__ */ new Map());
|
|
11706
|
+
if (fields === null) return;
|
|
11707
|
+
const kept = [...fields].filter(
|
|
11708
|
+
([key]) => options.keepSignIn || key !== "token" && key !== "deviceId"
|
|
11709
|
+
);
|
|
11710
|
+
fs16.mkdirSync(configDir, { recursive: true, mode: 448 });
|
|
11711
|
+
fs16.writeFileSync(file, `${JSON.stringify({ ...Object.fromEntries(kept), url }, null, 2)}
|
|
11431
11712
|
`, {
|
|
11432
11713
|
mode: 384
|
|
11433
11714
|
});
|
|
@@ -11442,7 +11723,8 @@ var serverCommand = async (args, runtime = nodeServerRuntime()) => {
|
|
|
11442
11723
|
};
|
|
11443
11724
|
}
|
|
11444
11725
|
try {
|
|
11445
|
-
if (command === "setup" && rest
|
|
11726
|
+
if (command === "setup" && answersNoQuestion(rest) && runtime.prompter !== void 0) {
|
|
11727
|
+
parseSetupOptions(rest);
|
|
11446
11728
|
return await guidedSetup(runtime, runtime.prompter, rest);
|
|
11447
11729
|
}
|
|
11448
11730
|
return await underLock(
|
|
@@ -11928,17 +12210,17 @@ var scanSkillLibrary = (root) => {
|
|
|
11928
12210
|
const files = [];
|
|
11929
12211
|
let bytes = 0;
|
|
11930
12212
|
for (const absolute of walkFiles(skillDir)) {
|
|
11931
|
-
const
|
|
12213
|
+
const relative6 = path17.relative(skillDir, absolute).split(path17.sep).join("/");
|
|
11932
12214
|
const buffer = fs17.readFileSync(absolute);
|
|
11933
12215
|
if (buffer.byteLength > MAX_SKILL_FILE_BYTES) {
|
|
11934
|
-
notes.push({ skill: entry.name, message: `${
|
|
12216
|
+
notes.push({ skill: entry.name, message: `${relative6} is over 512KB \u2014 skipped` });
|
|
11935
12217
|
continue;
|
|
11936
12218
|
}
|
|
11937
12219
|
if (!isTextBuffer(buffer)) {
|
|
11938
|
-
notes.push({ skill: entry.name, message: `${
|
|
12220
|
+
notes.push({ skill: entry.name, message: `${relative6} is binary \u2014 skipped` });
|
|
11939
12221
|
continue;
|
|
11940
12222
|
}
|
|
11941
|
-
files.push({ path:
|
|
12223
|
+
files.push({ path: relative6, contents: buffer.toString("utf8") });
|
|
11942
12224
|
bytes += buffer.byteLength;
|
|
11943
12225
|
}
|
|
11944
12226
|
if (files.length > MAX_SKILL_FILES) {
|
|
@@ -12142,25 +12424,80 @@ var removeManagedBlock = (config, beginMarker, endMarker) => {
|
|
|
12142
12424
|
}
|
|
12143
12425
|
return success(`${config.slice(0, begin)}${after}`);
|
|
12144
12426
|
};
|
|
12145
|
-
var
|
|
12427
|
+
var LEGACY_ALIAS = "mend-ws";
|
|
12428
|
+
var decodeIdentityFile = (value) => {
|
|
12429
|
+
if (value === void 0) return null;
|
|
12430
|
+
if (!value.startsWith('"')) return value;
|
|
12431
|
+
if (!/^"(?:[^"\\]|\\["\\])*"$/.test(value)) return null;
|
|
12432
|
+
return value.slice(1, -1).replace(/\\(["\\])/g, "$1").replaceAll("%%", "%");
|
|
12433
|
+
};
|
|
12434
|
+
var blockFacts = (body, alias, legacy) => {
|
|
12435
|
+
const directive = (name) => new RegExp(`^\\s*${name}\\s+(.+?)\\s*$`, "im").exec(body)?.[1];
|
|
12436
|
+
const port = Number(directive("Port"));
|
|
12437
|
+
return {
|
|
12438
|
+
alias,
|
|
12439
|
+
legacy,
|
|
12440
|
+
hostname: directive("HostName") ?? null,
|
|
12441
|
+
port: Number.isInteger(port) && port > 0 ? port : null,
|
|
12442
|
+
identityFile: decodeIdentityFile(directive("IdentityFile"))
|
|
12443
|
+
};
|
|
12444
|
+
};
|
|
12445
|
+
var blockBody = (config, beginMarker, endMarker) => {
|
|
12446
|
+
const begin = config.indexOf(beginMarker);
|
|
12447
|
+
if (begin === -1) return null;
|
|
12448
|
+
const end = config.indexOf(endMarker, begin + beginMarker.length);
|
|
12449
|
+
return end === -1 ? null : config.slice(begin + beginMarker.length, end);
|
|
12450
|
+
};
|
|
12451
|
+
var listManagedWorkspaceSshBlocks = (config) => {
|
|
12452
|
+
const aliases = new Set(
|
|
12453
|
+
[...config.matchAll(/^# >>> mend workspace ssh (mend-ws-[a-z0-9-]+) \(managed\) >>>$/gm)].map((match) => match[1]).filter((alias) => alias !== void 0)
|
|
12454
|
+
);
|
|
12455
|
+
const blocks = [];
|
|
12456
|
+
for (const alias of aliases) {
|
|
12457
|
+
const body = blockBody(config, blockBegin(alias), blockEnd(alias));
|
|
12458
|
+
if (body !== null) blocks.push(blockFacts(body, alias, false));
|
|
12459
|
+
}
|
|
12460
|
+
const legacy = blockBody(config, LEGACY_BLOCK_BEGIN, LEGACY_BLOCK_END);
|
|
12461
|
+
if (legacy !== null) blocks.push(blockFacts(legacy, LEGACY_ALIAS, true));
|
|
12462
|
+
return blocks;
|
|
12463
|
+
};
|
|
12464
|
+
var workspaceSshAlias = (serverUrl) => {
|
|
12465
|
+
const target = parseWorkspaceSshTarget({ serverUrl, publishedPort: 22 });
|
|
12466
|
+
return target.ok ? target.value.alias : null;
|
|
12467
|
+
};
|
|
12468
|
+
var stripManagedWorkspaceSshBlocks = (existing, owned) => {
|
|
12146
12469
|
let config = existing;
|
|
12147
|
-
|
|
12148
|
-
const
|
|
12149
|
-
|
|
12150
|
-
|
|
12151
|
-
|
|
12152
|
-
|
|
12470
|
+
const removed = [];
|
|
12471
|
+
const kept = [];
|
|
12472
|
+
let legacy = null;
|
|
12473
|
+
for (const block of listManagedWorkspaceSshBlocks(existing)) {
|
|
12474
|
+
if (block.legacy) {
|
|
12475
|
+
legacy = block;
|
|
12476
|
+
continue;
|
|
12477
|
+
}
|
|
12478
|
+
if (!owned(block)) {
|
|
12479
|
+
kept.push(block);
|
|
12480
|
+
continue;
|
|
12481
|
+
}
|
|
12482
|
+
const stripped = removeManagedBlock(config, blockBegin(block.alias), blockEnd(block.alias));
|
|
12153
12483
|
if (!stripped.ok) return stripped;
|
|
12154
12484
|
config = stripped.value;
|
|
12155
|
-
removed
|
|
12485
|
+
removed.push(block);
|
|
12156
12486
|
}
|
|
12157
|
-
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
|
|
12161
|
-
|
|
12487
|
+
for (const alias of config.matchAll(
|
|
12488
|
+
/^# >>> mend workspace ssh (mend-ws-[a-z0-9-]+) \(managed\) >>>$/gm
|
|
12489
|
+
)) {
|
|
12490
|
+
const name = alias[1] ?? "";
|
|
12491
|
+
if (blockBody(config, blockBegin(name), blockEnd(name)) === null) {
|
|
12492
|
+
return failure(
|
|
12493
|
+
new WorkspaceSshError(
|
|
12494
|
+
"config",
|
|
12495
|
+
`Managed SSH config block beginning with "${blockBegin(name)}" has no closing marker.`
|
|
12496
|
+
)
|
|
12497
|
+
);
|
|
12498
|
+
}
|
|
12162
12499
|
}
|
|
12163
|
-
return success({ config, removed });
|
|
12500
|
+
return success({ config, removed, kept, legacy });
|
|
12164
12501
|
};
|
|
12165
12502
|
var containsExactHost = (config, alias) => config.split("\n").some((line) => {
|
|
12166
12503
|
const match = /^\s*Host\s+(.+?)\s*$/i.exec(line);
|
|
@@ -12173,11 +12510,9 @@ var reconcileWorkspaceSshConfig = (existing, target, identityFile) => {
|
|
|
12173
12510
|
blockEnd(target.alias)
|
|
12174
12511
|
);
|
|
12175
12512
|
if (!withoutCurrent.ok) return withoutCurrent;
|
|
12176
|
-
const
|
|
12177
|
-
|
|
12178
|
-
|
|
12179
|
-
LEGACY_BLOCK_END
|
|
12180
|
-
);
|
|
12513
|
+
const legacy = listManagedWorkspaceSshBlocks(withoutCurrent.value).find((block2) => block2.legacy);
|
|
12514
|
+
const legacyIsThisServer = legacy === void 0 || legacy.hostname?.toLowerCase() === target.hostname.toLowerCase() && (legacy.port ?? 22) === target.port;
|
|
12515
|
+
const withoutLegacy = legacyIsThisServer ? removeManagedBlock(withoutCurrent.value, LEGACY_BLOCK_BEGIN, LEGACY_BLOCK_END) : withoutCurrent;
|
|
12181
12516
|
if (!withoutLegacy.ok) return withoutLegacy;
|
|
12182
12517
|
if (containsExactHost(withoutLegacy.value, target.alias)) {
|
|
12183
12518
|
return failure(
|
|
@@ -12225,17 +12560,8 @@ var readText = (file) => {
|
|
|
12225
12560
|
}
|
|
12226
12561
|
};
|
|
12227
12562
|
var configuredWorkspaceSshIdentityFile = (config, target) => {
|
|
12228
|
-
const
|
|
12229
|
-
|
|
12230
|
-
const end = config.indexOf(blockEnd(target.alias), begin);
|
|
12231
|
-
if (end === -1) return null;
|
|
12232
|
-
const block = config.slice(begin, end);
|
|
12233
|
-
const match = /^\s*IdentityFile\s+(.+?)\s*$/m.exec(block);
|
|
12234
|
-
const value = match?.[1];
|
|
12235
|
-
if (value === void 0) return null;
|
|
12236
|
-
if (!value.startsWith('"')) return value;
|
|
12237
|
-
if (!/^"(?:[^"\\]|\\["\\])*"$/.test(value)) return null;
|
|
12238
|
-
return value.slice(1, -1).replace(/\\(["\\])/g, "$1").replaceAll("%%", "%");
|
|
12563
|
+
const body = blockBody(config, blockBegin(target.alias), blockEnd(target.alias));
|
|
12564
|
+
return body === null ? null : blockFacts(body, target.alias, false).identityFile;
|
|
12239
12565
|
};
|
|
12240
12566
|
var publicKeyPath = (keyPath) => keyPath.endsWith(".pub") ? keyPath : `${keyPath}.pub`;
|
|
12241
12567
|
var readRequiredKey = (keyPath, source) => {
|
|
@@ -12542,8 +12868,52 @@ var setup = async (api2, cliHome, serverUrl, args) => {
|
|
|
12542
12868
|
);
|
|
12543
12869
|
say5("");
|
|
12544
12870
|
say5(
|
|
12545
|
-
`connect with ssh ${view.gateway.usernamePrefix}-<workspace
|
|
12871
|
+
`connect with mend ssh <session> ${dim5(`\xB7 prints the ssh command for one session's workspace (ssh ${view.gateway.usernamePrefix}-<workspace>@${parsedTarget.value.alias}); the VS Code extension connects by itself`)}`
|
|
12872
|
+
);
|
|
12873
|
+
};
|
|
12874
|
+
var workspaceSshCommand = (usernamePrefix, workspaceId, alias) => `ssh ${usernamePrefix}-${workspaceId}@${alias}`;
|
|
12875
|
+
var sessionSsh = async (api2, cliHome, serverUrl, session, args) => {
|
|
12876
|
+
const id8 = session.id.slice(0, 8);
|
|
12877
|
+
const workspaceId = session.sealantWorkspaceId ?? null;
|
|
12878
|
+
if (workspaceId === null) {
|
|
12879
|
+
return showFailure(
|
|
12880
|
+
`session ${id8} has no running workspace to ssh into (${session.status}) \xB7 resume the session, then run mend ssh ${id8} again`
|
|
12881
|
+
);
|
|
12882
|
+
}
|
|
12883
|
+
const view = await api2("GET", "/workspace-ssh");
|
|
12884
|
+
if (view.gateway === null)
|
|
12885
|
+
return showFailure("This deployment exposes no workspace SSH gateway.");
|
|
12886
|
+
const parsedTarget = parseWorkspaceSshTarget({
|
|
12887
|
+
serverUrl,
|
|
12888
|
+
publishedPort: view.gateway.port,
|
|
12889
|
+
hostnameOverride: flagValue2(args, "--host")
|
|
12890
|
+
});
|
|
12891
|
+
if (parsedTarget.ok === false) return showFailure(parsedTarget.error.message);
|
|
12892
|
+
console.log(
|
|
12893
|
+
workspaceSshCommand(view.gateway.usernamePrefix, workspaceId, parsedTarget.value.alias)
|
|
12546
12894
|
);
|
|
12895
|
+
const config = readWorkspaceSshConfig(sshConfigPath());
|
|
12896
|
+
const picked = config.ok === false ? null : pickWorkspaceSshKey({
|
|
12897
|
+
configHome: cliHome,
|
|
12898
|
+
configuredIdentityFile: configuredWorkspaceSshIdentityFile(
|
|
12899
|
+
config.value,
|
|
12900
|
+
parsedTarget.value
|
|
12901
|
+
),
|
|
12902
|
+
create: false
|
|
12903
|
+
});
|
|
12904
|
+
const ready = config.ok && picked !== null && picked.ok && inspectWorkspaceSshReadiness({
|
|
12905
|
+
config: config.value,
|
|
12906
|
+
target: parsedTarget.value,
|
|
12907
|
+
key: picked.value,
|
|
12908
|
+
registeredFingerprints: view.keys.map((key) => key.fingerprint)
|
|
12909
|
+
}).ready;
|
|
12910
|
+
if (!ready) {
|
|
12911
|
+
console.error(
|
|
12912
|
+
redactCredentials(
|
|
12913
|
+
`${warn("not set up")} ${dim5(`\xB7 this machine has no ready Host ${parsedTarget.value.alias} block or registered key \xB7 run: mend ssh setup`)}`
|
|
12914
|
+
)
|
|
12915
|
+
);
|
|
12916
|
+
}
|
|
12547
12917
|
};
|
|
12548
12918
|
var errorText = (cause) => cause instanceof Error ? cause.message : String(cause);
|
|
12549
12919
|
var thisMachineKeys = (view, cliHome, serverUrl) => {
|
|
@@ -12723,7 +13093,7 @@ var keysCommand = async (api2, cliHome, serverUrl, args) => {
|
|
|
12723
13093
|
);
|
|
12724
13094
|
}
|
|
12725
13095
|
};
|
|
12726
|
-
var sshCommand = async (args, api2, cliHome, serverUrl) => {
|
|
13096
|
+
var sshCommand = async (args, api2, cliHome, serverUrl, findSession2) => {
|
|
12727
13097
|
const [subcommand, ...rest] = args;
|
|
12728
13098
|
switch (subcommand) {
|
|
12729
13099
|
case void 0:
|
|
@@ -12734,14 +13104,18 @@ var sshCommand = async (args, api2, cliHome, serverUrl) => {
|
|
|
12734
13104
|
case "keys":
|
|
12735
13105
|
return keysCommand(api2, cliHome, serverUrl, rest);
|
|
12736
13106
|
default:
|
|
13107
|
+
if (/^[0-9a-f][0-9a-f-]*$/i.test(subcommand)) {
|
|
13108
|
+
return sessionSsh(api2, cliHome, serverUrl, await findSession2(subcommand), rest);
|
|
13109
|
+
}
|
|
12737
13110
|
showFailure(
|
|
12738
|
-
`Unknown ssh subcommand "${subcommand}". Try: mend ssh \xB7 mend ssh setup [--key <path>] [--host <hostname>] \xB7 mend ssh keys [remove <fingerprint>]`
|
|
13111
|
+
`Unknown ssh subcommand "${subcommand}". Try: mend ssh \xB7 mend ssh <session> \xB7 mend ssh setup [--key <path>] [--host <hostname>] \xB7 mend ssh keys [remove <fingerprint>]`
|
|
12739
13112
|
);
|
|
12740
13113
|
}
|
|
12741
13114
|
};
|
|
12742
13115
|
|
|
12743
13116
|
// src/uninstall.ts
|
|
12744
13117
|
import * as fs20 from "node:fs";
|
|
13118
|
+
import * as os13 from "node:os";
|
|
12745
13119
|
import * as path20 from "node:path";
|
|
12746
13120
|
var UNINSTALL_USAGE = "usage: mend uninstall [--all | --server | --home] [--yes]";
|
|
12747
13121
|
var parseUninstallArgs = (args) => {
|
|
@@ -12811,16 +13185,26 @@ var exists = (file) => {
|
|
|
12811
13185
|
return false;
|
|
12812
13186
|
}
|
|
12813
13187
|
};
|
|
12814
|
-
var
|
|
12815
|
-
let config;
|
|
13188
|
+
var readSshBlocks = (sshConfigFile) => {
|
|
12816
13189
|
try {
|
|
12817
|
-
|
|
13190
|
+
return listManagedWorkspaceSshBlocks(fs20.readFileSync(sshConfigFile, "utf8"));
|
|
12818
13191
|
} catch {
|
|
12819
|
-
return
|
|
13192
|
+
return [];
|
|
12820
13193
|
}
|
|
12821
|
-
const stripped = stripManagedWorkspaceSshBlocks(config);
|
|
12822
|
-
return stripped.ok ? stripped.value.removed : 0;
|
|
12823
13194
|
};
|
|
13195
|
+
var sshBlockOwned = (owners) => (block) => {
|
|
13196
|
+
if (block.legacy) return false;
|
|
13197
|
+
if (owners.urls.some((url) => workspaceSshAlias(url) === block.alias)) return true;
|
|
13198
|
+
const { gateway } = owners;
|
|
13199
|
+
return gateway !== null && block.port === gateway.port && block.hostname !== null && gateway.hosts.includes(block.hostname.toLowerCase());
|
|
13200
|
+
};
|
|
13201
|
+
var blockLabel = (block) => `Host ${block.alias}${block.hostname === null ? "" : ` \u2192 ${block.hostname}${block.port === null ? "" : `:${block.port}`}`}`;
|
|
13202
|
+
var within = (directory, file) => {
|
|
13203
|
+
const resolved = file.startsWith("~/") ? path20.join(os13.homedir(), file.slice(2)) : file;
|
|
13204
|
+
const relative6 = path20.relative(directory, resolved);
|
|
13205
|
+
return relative6 !== "" && !relative6.startsWith("..") && !path20.isAbsolute(relative6);
|
|
13206
|
+
};
|
|
13207
|
+
var legacyBlockNote = (block, sshConfigFile) => `${sshConfigFile}: ${blockLabel(block)} stays. An older mend ssh setup wrote it, and nothing in it says which server it is for. If it is this one's, delete it from the line "# >>> mend workspace ssh (managed by \`mend ssh setup\`) >>>" to "# <<< mend workspace ssh <<<"`;
|
|
12824
13208
|
var plural = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
|
|
12825
13209
|
var listOf = (names, shown = 3) => `${names.slice(0, shown).join(", ")}${names.length > shown ? `, and ${names.length - shown} more` : ""}`;
|
|
12826
13210
|
var formatBytes5 = (bytes) => {
|
|
@@ -12890,14 +13274,17 @@ var findWorkspaces = async (run2, context, controlVolume) => {
|
|
|
12890
13274
|
"--filter",
|
|
12891
13275
|
`volume=${controlVolume}`,
|
|
12892
13276
|
"--format",
|
|
12893
|
-
|
|
13277
|
+
'{{.Names}} {{.State}} {{.Image}} {{.Label "com.docker.compose.project"}}'
|
|
12894
13278
|
]);
|
|
12895
13279
|
if (mounted.status !== 0) return { problem: detail(mounted) };
|
|
12896
|
-
const
|
|
13280
|
+
const sessionRows = rows(mounted.stdout).filter(
|
|
13281
|
+
([, , , project2]) => project2 !== MEND_DOCKER_NAMESPACE.project
|
|
13282
|
+
);
|
|
13283
|
+
const workspaces = sessionRows.flatMap(
|
|
12897
13284
|
([name, state]) => name !== void 0 && DOCKER_NAME.test(name) ? [{ name, running: state === "running" }] : []
|
|
12898
13285
|
);
|
|
12899
13286
|
const images = new Set(
|
|
12900
|
-
|
|
13287
|
+
sessionRows.flatMap(
|
|
12901
13288
|
([, , image]) => image !== void 0 && IMAGE_REFERENCE2.test(image) ? [image] : []
|
|
12902
13289
|
)
|
|
12903
13290
|
);
|
|
@@ -13070,7 +13457,7 @@ var parseUrl2 = (value) => {
|
|
|
13070
13457
|
}
|
|
13071
13458
|
};
|
|
13072
13459
|
var isLoopback = (host) => ["localhost", "127.0.0.1", "[::1]", "::1"].includes(host);
|
|
13073
|
-
var
|
|
13460
|
+
var portOf2 = (url) => url.port || (url.protocol === "https:" ? "443" : "80");
|
|
13074
13461
|
var signedInTo = (signedInUrl, appUrl, edgeHost) => {
|
|
13075
13462
|
const signed = parseUrl2(signedInUrl);
|
|
13076
13463
|
if (signed === null) return false;
|
|
@@ -13079,7 +13466,7 @@ var signedInTo = (signedInUrl, appUrl, edgeHost) => {
|
|
|
13079
13466
|
const app = parseUrl2(appUrl);
|
|
13080
13467
|
if (app === null) return false;
|
|
13081
13468
|
if (signed.origin === app.origin) return true;
|
|
13082
|
-
return isLoopback(signed.hostname) &&
|
|
13469
|
+
return isLoopback(signed.hostname) && portOf2(signed) === portOf2(app);
|
|
13083
13470
|
};
|
|
13084
13471
|
var describeUninstall = async (runtime, scope) => {
|
|
13085
13472
|
let server = null;
|
|
@@ -13145,6 +13532,8 @@ var describeUninstall = async (runtime, scope) => {
|
|
|
13145
13532
|
...composed.status === 0 ? composed.stdout.split(/\s+/) : [],
|
|
13146
13533
|
...guard.status === 0 ? [guard.stdout.trim()] : [],
|
|
13147
13534
|
DOCKER_SERVICE_IMAGE,
|
|
13535
|
+
// The edge's image stays after `--no-edge`, when the overlay no longer names it.
|
|
13536
|
+
EDGE_IMAGE,
|
|
13148
13537
|
...holdings.images
|
|
13149
13538
|
].filter((image) => IMAGE_REFERENCE2.test(image) && image !== mendImage);
|
|
13150
13539
|
const found = await findImages(run2, context, [...new Set(candidates)]);
|
|
@@ -13161,6 +13550,7 @@ var describeUninstall = async (runtime, scope) => {
|
|
|
13161
13550
|
appUrl: config.appUrl,
|
|
13162
13551
|
dockerContext: context,
|
|
13163
13552
|
edgeHost: config.edgeHost ?? null,
|
|
13553
|
+
sshPort: config.sshPort,
|
|
13164
13554
|
mirrors: mirrorServices(config.mirrors),
|
|
13165
13555
|
t3GatewayVolume,
|
|
13166
13556
|
generations: countEntries(path20.join(configDir, "generations")),
|
|
@@ -13176,10 +13566,35 @@ var describeUninstall = async (runtime, scope) => {
|
|
|
13176
13566
|
if (scope !== "server") {
|
|
13177
13567
|
const cliConfig = path20.join(runtime.cliHome, "cli.json");
|
|
13178
13568
|
const sshDirectory = path20.join(runtime.cliHome, "ssh");
|
|
13569
|
+
const installed = isInstallation(server) && server.appUrl !== "" ? server : null;
|
|
13570
|
+
const appHost = installed === null ? null : parseUrl2(installed.appUrl)?.hostname;
|
|
13571
|
+
const owned = sshBlockOwned({
|
|
13572
|
+
urls: [
|
|
13573
|
+
...runtime.signedIn === null ? [] : [runtime.signedIn.url],
|
|
13574
|
+
...installed === null ? [] : [installed.appUrl],
|
|
13575
|
+
...installed?.edgeHost == null ? [] : [`https://${installed.edgeHost}`]
|
|
13576
|
+
],
|
|
13577
|
+
gateway: installed?.sshPort === void 0 ? null : {
|
|
13578
|
+
hosts: [
|
|
13579
|
+
"localhost",
|
|
13580
|
+
"127.0.0.1",
|
|
13581
|
+
"::1",
|
|
13582
|
+
...appHost == null ? [] : [appHost.replace(/^\[|\]$/g, "").toLowerCase()],
|
|
13583
|
+
...installed.edgeHost == null ? [] : [installed.edgeHost.toLowerCase()]
|
|
13584
|
+
],
|
|
13585
|
+
port: installed.sshPort
|
|
13586
|
+
}
|
|
13587
|
+
});
|
|
13588
|
+
const blocks = readSshBlocks(runtime.sshConfigFile);
|
|
13589
|
+
const kept = blocks.filter((block) => !owned(block));
|
|
13590
|
+
const keyUsers = kept.filter((block) => block.identityFile !== null && within(sshDirectory, block.identityFile)).map((block) => block.alias);
|
|
13591
|
+
const sshDirectoryHere = exists(sshDirectory);
|
|
13179
13592
|
home = {
|
|
13180
13593
|
cliConfig: exists(cliConfig) ? cliConfig : null,
|
|
13181
|
-
sshDirectory:
|
|
13182
|
-
|
|
13594
|
+
sshDirectory: sshDirectoryHere && keyUsers.length === 0 ? sshDirectory : null,
|
|
13595
|
+
sshBlocks: blocks.filter(owned),
|
|
13596
|
+
sshBlocksKept: kept,
|
|
13597
|
+
...sshDirectoryHere && keyUsers.length > 0 ? { sshDirectoryKept: { directory: sshDirectory, aliases: keyUsers } } : {},
|
|
13183
13598
|
signedIn: runtime.signedIn,
|
|
13184
13599
|
signedInToThisServer: runtime.signedIn !== null && isInstallation(server) && server.appUrl !== "" && signedInTo(runtime.signedIn.url, server.appUrl, server.edgeHost)
|
|
13185
13600
|
};
|
|
@@ -13270,19 +13685,28 @@ var planLines = (plan, configDir) => {
|
|
|
13270
13685
|
);
|
|
13271
13686
|
}
|
|
13272
13687
|
if (plan.home.sshDirectory !== null) parts.push(plan.home.sshDirectory);
|
|
13273
|
-
|
|
13274
|
-
parts.push(`${plural(plan.home.managedSshBlocks, "managed block")} in ~/.ssh/config`);
|
|
13275
|
-
}
|
|
13688
|
+
for (const block of plan.home.sshBlocks) parts.push(`~/.ssh/config ${blockLabel(block)}`);
|
|
13276
13689
|
if (plan.home.signedIn !== null && plan.home.signedInToThisServer !== true) {
|
|
13277
13690
|
parts.push(`this machine's workspace ssh key on ${plan.home.signedIn.url}, if registered`);
|
|
13278
13691
|
}
|
|
13279
13692
|
lines.push(parts.length === 0 ? "home nothing of Mend's here" : `home ${parts[0]}`);
|
|
13280
13693
|
for (const part of parts.slice(1)) lines.push(` ${part}`);
|
|
13694
|
+
for (const block of plan.home.sshBlocksKept ?? []) {
|
|
13695
|
+
lines.push(
|
|
13696
|
+
block.legacy ? `stays ~/.ssh/config ${blockLabel(block)}: an older mend ssh setup wrote it and it names no server` : `stays ~/.ssh/config ${blockLabel(block)}: another server's`
|
|
13697
|
+
);
|
|
13698
|
+
}
|
|
13699
|
+
const keyKept = plan.home.sshDirectoryKept;
|
|
13700
|
+
if (keyKept !== void 0) {
|
|
13701
|
+
lines.push(
|
|
13702
|
+
`stays ${keyKept.directory}: ${keyKept.aliases.map((alias) => `Host ${alias}`).join(", ")} ${keyKept.aliases.length === 1 ? "signs" : "sign"} with a key in it`
|
|
13703
|
+
);
|
|
13704
|
+
}
|
|
13281
13705
|
}
|
|
13282
13706
|
return lines;
|
|
13283
13707
|
};
|
|
13284
13708
|
var planDeletesData = (plan) => plan.server !== null && plan.server !== "none";
|
|
13285
|
-
var planIsEmpty = (plan) => (plan.server === null || plan.server === "none") && (plan.home === null || plan.home.cliConfig === null && plan.home.sshDirectory === null && plan.home.
|
|
13709
|
+
var planIsEmpty = (plan) => (plan.server === null || plan.server === "none") && (plan.home === null || plan.home.cliConfig === null && plan.home.sshDirectory === null && plan.home.sshBlocks.length === 0);
|
|
13286
13710
|
var removeWorkspaces = async (run2, context, holdings, report) => {
|
|
13287
13711
|
const left = [];
|
|
13288
13712
|
const containers = [
|
|
@@ -13579,21 +14003,28 @@ var removeHostExtras = async (runtime, context, extras, report) => {
|
|
|
13579
14003
|
report.remaining.push(HOST_USER_NAMESPACE_SYSCTL_FILE);
|
|
13580
14004
|
}
|
|
13581
14005
|
const removed = [];
|
|
13582
|
-
|
|
14006
|
+
let refused = [];
|
|
13583
14007
|
for (const image of extras.images) {
|
|
13584
14008
|
const gone = await dockerIn(run2, context, ["image", "rm", image]);
|
|
13585
14009
|
if (gone.status === 0 || notFound(gone)) removed.push(image);
|
|
13586
|
-
else
|
|
14010
|
+
else refused.push({ image, why: detail(gone) });
|
|
13587
14011
|
}
|
|
14012
|
+
const retried = [];
|
|
14013
|
+
for (const { image } of refused) {
|
|
14014
|
+
const gone = await dockerIn(run2, context, ["image", "rm", image]);
|
|
14015
|
+
if (gone.status === 0 || notFound(gone)) removed.push(image);
|
|
14016
|
+
else retried.push({ image, why: detail(gone) });
|
|
14017
|
+
}
|
|
14018
|
+
refused = retried;
|
|
13588
14019
|
if (removed.length > 0) {
|
|
13589
14020
|
report.write(`removed ${plural(removed.length, "image")} (${listOf(removed, 4)})`);
|
|
13590
14021
|
}
|
|
13591
|
-
|
|
14022
|
+
for (const { image, why } of refused) {
|
|
13592
14023
|
report.leftovers.push(
|
|
13593
|
-
|
|
14024
|
+
`image ${image}: ${why}. To remove it: docker --context ${context} image rm ${image}`
|
|
13594
14025
|
);
|
|
13595
|
-
report.remaining.push(plural(kept.length, "image"));
|
|
13596
14026
|
}
|
|
14027
|
+
if (refused.length > 0) report.remaining.push(plural(refused.length, "image"));
|
|
13597
14028
|
};
|
|
13598
14029
|
var clearBuildCache = async (runtime, context) => {
|
|
13599
14030
|
const pruned = await dockerIn(
|
|
@@ -13615,15 +14046,16 @@ var removeHome = async (runtime, plan, report) => {
|
|
|
13615
14046
|
fs20.rmSync(plan.sshDirectory, { recursive: true, force: true });
|
|
13616
14047
|
server.writeLine(`removed ${plan.sshDirectory}`);
|
|
13617
14048
|
}
|
|
13618
|
-
if (plan.
|
|
14049
|
+
if (plan.sshBlocks.length > 0) {
|
|
14050
|
+
const planned = new Set(plan.sshBlocks.map((block) => block.alias));
|
|
13619
14051
|
try {
|
|
13620
14052
|
const before = fs20.readFileSync(runtime.sshConfigFile, "utf8");
|
|
13621
|
-
const stripped = stripManagedWorkspaceSshBlocks(before);
|
|
14053
|
+
const stripped = stripManagedWorkspaceSshBlocks(before, (block) => planned.has(block.alias));
|
|
13622
14054
|
if (!stripped.ok) throw stripped.error;
|
|
13623
|
-
if (stripped.value.removed > 0) {
|
|
14055
|
+
if (stripped.value.removed.length > 0) {
|
|
13624
14056
|
fs20.writeFileSync(runtime.sshConfigFile, stripped.value.config, { mode: 384 });
|
|
13625
14057
|
server.writeLine(
|
|
13626
|
-
`removed ${
|
|
14058
|
+
`removed ${stripped.value.removed.map((block) => `Host ${block.alias}`).join(", ")} from ${runtime.sshConfigFile}`
|
|
13627
14059
|
);
|
|
13628
14060
|
}
|
|
13629
14061
|
} catch (cause) {
|
|
@@ -13632,6 +14064,17 @@ var removeHome = async (runtime, plan, report) => {
|
|
|
13632
14064
|
);
|
|
13633
14065
|
}
|
|
13634
14066
|
}
|
|
14067
|
+
for (const block of plan.sshBlocksKept ?? []) {
|
|
14068
|
+
if (!block.legacy) continue;
|
|
14069
|
+
report.leftovers.push(legacyBlockNote(block, runtime.sshConfigFile));
|
|
14070
|
+
report.remaining.push(`Host ${block.alias} in ${runtime.sshConfigFile}`);
|
|
14071
|
+
}
|
|
14072
|
+
const keyKept = plan.sshDirectoryKept;
|
|
14073
|
+
if (keyKept !== void 0) {
|
|
14074
|
+
report.leftovers.push(
|
|
14075
|
+
`${keyKept.directory}: ${keyKept.aliases.map((alias) => `Host ${alias}`).join(", ")} in ${runtime.sshConfigFile} ${keyKept.aliases.length === 1 ? "signs" : "sign"} with a key in it, so it stays`
|
|
14076
|
+
);
|
|
14077
|
+
}
|
|
13635
14078
|
let remaining = [];
|
|
13636
14079
|
try {
|
|
13637
14080
|
remaining = fs20.readdirSync(runtime.cliHome);
|
|
@@ -13644,7 +14087,8 @@ var removeHome = async (runtime, plan, report) => {
|
|
|
13644
14087
|
return;
|
|
13645
14088
|
}
|
|
13646
14089
|
const serverFiles = remaining.filter((name) => SERVER_OWNED.has(name));
|
|
13647
|
-
const
|
|
14090
|
+
const keyDirectory = keyKept === void 0 ? null : path20.basename(keyKept.directory);
|
|
14091
|
+
const others = remaining.filter((name) => !SERVER_OWNED.has(name) && name !== keyDirectory);
|
|
13648
14092
|
if (serverFiles.length > 0 && !report.remaining.includes(runtime.cliHome)) {
|
|
13649
14093
|
report.leftovers.push(
|
|
13650
14094
|
`${runtime.cliHome}: ${serverFiles.join(", ")} ${serverFiles.length === 1 ? "is" : "are"} the server's configuration, which mend uninstall --server removes`
|
|
@@ -13905,10 +14349,10 @@ var worktreesRmCommand = async (deps, argv) => {
|
|
|
13905
14349
|
var mendCliHome = () => {
|
|
13906
14350
|
const xdg = process.env["XDG_CONFIG_HOME"];
|
|
13907
14351
|
const preferred = path21.join(
|
|
13908
|
-
xdg === void 0 || xdg === "" ? path21.join(
|
|
14352
|
+
xdg === void 0 || xdg === "" ? path21.join(os14.homedir(), ".config") : xdg,
|
|
13909
14353
|
"mend"
|
|
13910
14354
|
);
|
|
13911
|
-
const legacy = path21.join(
|
|
14355
|
+
const legacy = path21.join(os14.homedir(), ".mend");
|
|
13912
14356
|
return !fs21.existsSync(preferred) && fs21.existsSync(legacy) ? legacy : preferred;
|
|
13913
14357
|
};
|
|
13914
14358
|
var CONFIG_PATH = path21.join(mendCliHome(), "cli.json");
|
|
@@ -14202,11 +14646,8 @@ var adopt = async (config, args) => {
|
|
|
14202
14646
|
say7(
|
|
14203
14647
|
`${dim7(" visible to")} ${visibility === "private" ? "only you" : "everyone in the organization"}`
|
|
14204
14648
|
);
|
|
14205
|
-
|
|
14206
|
-
|
|
14207
|
-
} else if (project2.gitAuthMode === "bridge") {
|
|
14208
|
-
say7(`${dim7(" git auth")} bridge ${dim7("(signed through the connected `mend keys share`)")}`);
|
|
14209
|
-
}
|
|
14649
|
+
const gitAuth = adoptedGitAuth(source, project2.gitAuthMode);
|
|
14650
|
+
if (gitAuth !== null) say7(`${dim7(" git auth")} ${gitAuth.value} ${dim7(`(${gitAuth.note})`)}`);
|
|
14210
14651
|
say7(
|
|
14211
14652
|
`${dim7(" sessions start with:")} mend codex ${dim7("(from anywhere \u2014")} --project ${project2.name}${dim7(")")}`
|
|
14212
14653
|
);
|
|
@@ -15680,16 +16121,6 @@ var serviceCommand = async (config, args) => {
|
|
|
15680
16121
|
}
|
|
15681
16122
|
};
|
|
15682
16123
|
var kilobytes = (bytes) => bytes < 1024 ? `${bytes} B` : `${(bytes / 1024).toFixed(1)} KB`;
|
|
15683
|
-
var memoryPathOf = (name) => {
|
|
15684
|
-
if (name.startsWith(".")) return name;
|
|
15685
|
-
const single = AGENT_MEMORY_FILES.find((file) => file.path.endsWith(`/${name}`));
|
|
15686
|
-
if (single !== void 0) return single.path;
|
|
15687
|
-
const qualified = /^([a-z]+):(.+)$/.exec(name);
|
|
15688
|
-
const harness = qualified?.[1] ?? "claude";
|
|
15689
|
-
const rest = qualified?.[2] ?? name;
|
|
15690
|
-
const root = AGENT_MEMORY_ROOTS.find((candidate) => candidate.harness === harness)?.root;
|
|
15691
|
-
return root === void 0 ? name : `${root}/${rest}`;
|
|
15692
|
-
};
|
|
15693
16124
|
var memoryImport = async (config, args) => {
|
|
15694
16125
|
const repoRoot = cwdFacts(process.cwd()).repoRoot;
|
|
15695
16126
|
if (repoRoot === null) return fail7("run mend memory import inside the repository's checkout");
|
|
@@ -15744,7 +16175,7 @@ var memoryCommand = async (config, args) => {
|
|
|
15744
16175
|
(arg, index) => !arg.startsWith("--") && rest[index - 1] !== "--project"
|
|
15745
16176
|
);
|
|
15746
16177
|
if (name === void 0) return fail7(usageOf(`memory ${verb}`));
|
|
15747
|
-
const query = `?path=${encodeURIComponent(
|
|
16178
|
+
const query = `?path=${encodeURIComponent(agentMemoryPathOf(name))}`;
|
|
15748
16179
|
if (verb === "rm") {
|
|
15749
16180
|
const removed = await api(
|
|
15750
16181
|
config,
|
|
@@ -15790,7 +16221,7 @@ var secretsCommand = async (config, args) => {
|
|
|
15790
16221
|
if (verb === "add" || verb === "rm") {
|
|
15791
16222
|
const given = rest.find((arg, index) => !arg.startsWith("--") && rest[index - 1] !== "--from");
|
|
15792
16223
|
if (given === void 0) return fail7(usageOf(`secrets ${verb}`));
|
|
15793
|
-
const resolved = secretFilePathOf(given,
|
|
16224
|
+
const resolved = secretFilePathOf(given, os14.homedir());
|
|
15794
16225
|
if (resolved.issue !== null) return fail7(resolved.issue);
|
|
15795
16226
|
if (verb === "rm") {
|
|
15796
16227
|
const removed = await api(
|
|
@@ -15836,7 +16267,7 @@ var secretsCommand = async (config, args) => {
|
|
|
15836
16267
|
var isProvider = (value) => value === "claude" || value === "codex" || value === "github";
|
|
15837
16268
|
var readIfExists = (file) => fs21.existsSync(file) ? fs21.readFileSync(file, "utf8") : null;
|
|
15838
16269
|
var localCredential = (provider) => {
|
|
15839
|
-
const home =
|
|
16270
|
+
const home = os14.homedir();
|
|
15840
16271
|
switch (provider) {
|
|
15841
16272
|
case "codex":
|
|
15842
16273
|
return readIfExists(
|
|
@@ -16188,7 +16619,7 @@ var uninstallCommand = async (config, args) => {
|
|
|
16188
16619
|
const runtime = {
|
|
16189
16620
|
server,
|
|
16190
16621
|
cliHome: mendCliHome(),
|
|
16191
|
-
sshConfigFile: path21.join(
|
|
16622
|
+
sshConfigFile: path21.join(os14.homedir(), ".ssh", "config"),
|
|
16192
16623
|
signedIn: config.token === null || !fs21.existsSync(CONFIG_PATH) ? null : { url: config.url, deviceId: config.deviceId },
|
|
16193
16624
|
revokeDevice: async () => {
|
|
16194
16625
|
if (config.deviceId === null) return "no device id saved";
|
|
@@ -16206,7 +16637,10 @@ var uninstallCommand = async (config, args) => {
|
|
|
16206
16637
|
),
|
|
16207
16638
|
forgetSignIn: () => saveCliConfig({ ...config, token: null, deviceId: null })
|
|
16208
16639
|
};
|
|
16209
|
-
const plan = await describeUninstall(runtime, scope)
|
|
16640
|
+
const plan = await describeUninstall(runtime, scope).catch(
|
|
16641
|
+
(error) => error instanceof ServerStoreError ? error : Promise.reject(error)
|
|
16642
|
+
);
|
|
16643
|
+
if (plan instanceof ServerStoreError) return fail7(plan.message);
|
|
16210
16644
|
say7(dim7(`mend uninstall \xB7 ${scope === "all" ? "everything" : scope}`));
|
|
16211
16645
|
for (const line of planLines(plan, server.configDir)) say7(` ${line}`);
|
|
16212
16646
|
if (planIsEmpty(plan)) {
|
|
@@ -16280,7 +16714,7 @@ var keysShare = async (config) => {
|
|
|
16280
16714
|
return fail7("SSH_AUTH_SOCK is not set \u2014 start (or plug in) your ssh-agent first");
|
|
16281
16715
|
}
|
|
16282
16716
|
await shareAgent({
|
|
16283
|
-
url: () => socketUrl(config, "keys-bridge", { host:
|
|
16717
|
+
url: () => socketUrl(config, "keys-bridge", { host: os14.hostname() }),
|
|
16284
16718
|
agentSock,
|
|
16285
16719
|
signal: new AbortController().signal,
|
|
16286
16720
|
onEvent: (event) => {
|
|
@@ -16410,7 +16844,7 @@ ${usageOf("dotfiles repo")}`);
|
|
|
16410
16844
|
var dotfilesSync = async (config, args) => {
|
|
16411
16845
|
const all = args.includes("--all");
|
|
16412
16846
|
const requestedPaths = args.filter((arg) => !arg.startsWith("--"));
|
|
16413
|
-
const home =
|
|
16847
|
+
const home = os14.homedir();
|
|
16414
16848
|
if (!all && requestedPaths.length === 0) {
|
|
16415
16849
|
const found = scanDotfileCandidates(home);
|
|
16416
16850
|
if (found.length === 0) {
|
|
@@ -16437,13 +16871,13 @@ var dotfilesSync = async (config, args) => {
|
|
|
16437
16871
|
if ("error" in read) return fail7(read.error);
|
|
16438
16872
|
const result = await api(config, "POST", "/dotfiles/snapshot", {
|
|
16439
16873
|
files: read.files,
|
|
16440
|
-
source:
|
|
16874
|
+
source: os14.hostname(),
|
|
16441
16875
|
merge: false
|
|
16442
16876
|
});
|
|
16443
16877
|
const snapshot = result.snapshot;
|
|
16444
16878
|
if (snapshot === null) return fail7("the server accepted the sync but reports no snapshot");
|
|
16445
16879
|
say7(
|
|
16446
|
-
`${green7("synced")} ${snapshot.files.length} file${snapshot.files.length === 1 ? "" : "s"} from ${
|
|
16880
|
+
`${green7("synced")} ${snapshot.files.length} file${snapshot.files.length === 1 ? "" : "s"} from ${os14.hostname()} \xB7 ${dim7(snapshot.sha.slice(0, 7))} ${dim7("\u2014 applies from the next session launch")}`
|
|
16447
16881
|
);
|
|
16448
16882
|
};
|
|
16449
16883
|
var envLoad = async (config, args) => {
|
|
@@ -16670,7 +17104,7 @@ var skillsList = async (config, args) => {
|
|
|
16670
17104
|
};
|
|
16671
17105
|
var skillsPush = async (config, args) => {
|
|
16672
17106
|
const dirFlag = takeFlagValue4(args, "--dir");
|
|
16673
|
-
const root = dirFlag === null ? path21.join(
|
|
17107
|
+
const root = dirFlag === null ? path21.join(os14.homedir(), DEFAULT_SKILLS_DIR) : path21.resolve(dirFlag);
|
|
16674
17108
|
const scanned = scanSkillLibrary(root);
|
|
16675
17109
|
if ("error" in scanned) return fail7(scanned.error);
|
|
16676
17110
|
for (const note of scanned.notes) say7(dim7(` ${note.skill}: ${note.message}`));
|
|
@@ -16850,17 +17284,22 @@ var restoreTerminal = () => {
|
|
|
16850
17284
|
};
|
|
16851
17285
|
process.once("exit", restoreTerminal);
|
|
16852
17286
|
var terminalGone = false;
|
|
17287
|
+
var readerGone = false;
|
|
16853
17288
|
var stopForegroundSession = null;
|
|
16854
17289
|
var exitOnceStopped = async (stop) => process.exit(await stop() ? 0 : 1);
|
|
16855
17290
|
var onStreamError = (stream) => (error) => {
|
|
17291
|
+
if (readerGone) return;
|
|
16856
17292
|
const closedTerminal = stream.isTTY === true && (error.code === "EIO" || error.code === "EPIPE");
|
|
16857
17293
|
if (!closedTerminal && error.code !== "EPIPE") throw error;
|
|
16858
17294
|
if (recordedOutput) return;
|
|
16859
|
-
if (!closedTerminal)
|
|
17295
|
+
if (!closedTerminal) {
|
|
17296
|
+
readerGone = true;
|
|
17297
|
+
return whenServerLockReleased(() => process.exit(0));
|
|
17298
|
+
}
|
|
16860
17299
|
if (terminalGone) return;
|
|
16861
17300
|
terminalGone = true;
|
|
16862
17301
|
const stop = stopForegroundSession;
|
|
16863
|
-
if (stop === null) process.exit(0);
|
|
17302
|
+
if (stop === null) return whenServerLockReleased(() => process.exit(0));
|
|
16864
17303
|
void exitOnceStopped(stop);
|
|
16865
17304
|
};
|
|
16866
17305
|
process.stdout.on("error", onStreamError(process.stdout));
|
|
@@ -17679,7 +18118,7 @@ var dashboard = async (config, options = {}) => {
|
|
|
17679
18118
|
);
|
|
17680
18119
|
process.exit(rerun.status ?? 0);
|
|
17681
18120
|
}
|
|
17682
|
-
const { runDashboard } = await import("./dashboard-
|
|
18121
|
+
const { runDashboard } = await import("./dashboard-4BJL72T6.js");
|
|
17683
18122
|
const agentShare = await startShareIfBridge(config);
|
|
17684
18123
|
const tunnels = options.noTunnel === true || serverIsLocal(config) ? null : createServiceTunnels({
|
|
17685
18124
|
listServices: () => fetchServices(config),
|
|
@@ -17713,7 +18152,7 @@ var startShareIfBridge = async (config) => {
|
|
|
17713
18152
|
}
|
|
17714
18153
|
if (access.mode !== "bridge") return null;
|
|
17715
18154
|
return startAgentShare({
|
|
17716
|
-
url: () => socketUrl(config, "keys-bridge", { host:
|
|
18155
|
+
url: () => socketUrl(config, "keys-bridge", { host: os14.hostname() }),
|
|
17717
18156
|
agentSock
|
|
17718
18157
|
});
|
|
17719
18158
|
};
|
|
@@ -17753,7 +18192,7 @@ var manCommand = (words) => {
|
|
|
17753
18192
|
}
|
|
17754
18193
|
const version = cliVersion();
|
|
17755
18194
|
const page = doc === null ? renderManIndex(version) : renderManPage(doc, version);
|
|
17756
|
-
const file = path21.join(
|
|
18195
|
+
const file = path21.join(os14.tmpdir(), `mend-man-${process.pid}-${manFileName(doc)}`);
|
|
17757
18196
|
fs21.writeFileSync(file, page);
|
|
17758
18197
|
const result = spawnSync6("man", ["-l", file], { stdio: "inherit" });
|
|
17759
18198
|
fs21.rmSync(file, { force: true });
|
|
@@ -17851,7 +18290,7 @@ var main = async () => {
|
|
|
17851
18290
|
if (rest.includes("--bundle")) return doctorBundle(config, rest);
|
|
17852
18291
|
return doctorCommand(config, localCredential, claudeGrantSecret, async () => {
|
|
17853
18292
|
try {
|
|
17854
|
-
return
|
|
18293
|
+
return await readLocalServer(nodeServerRuntime().configDir);
|
|
17855
18294
|
} catch {
|
|
17856
18295
|
return null;
|
|
17857
18296
|
}
|
|
@@ -17859,7 +18298,13 @@ var main = async () => {
|
|
|
17859
18298
|
case "env":
|
|
17860
18299
|
return envCommand(config, rest);
|
|
17861
18300
|
case "ssh":
|
|
17862
|
-
return sshCommand(
|
|
18301
|
+
return sshCommand(
|
|
18302
|
+
rest,
|
|
18303
|
+
boundApi(config),
|
|
18304
|
+
mendCliHome(),
|
|
18305
|
+
config.url,
|
|
18306
|
+
(prefix) => resolveLiveSession(config, prefix, "ssh")
|
|
18307
|
+
);
|
|
17863
18308
|
case "completions":
|
|
17864
18309
|
return completionsCommand(rest);
|
|
17865
18310
|
case "__complete":
|