@kvbox/cli 0.5.43 → 0.5.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/kvbox.js CHANGED
@@ -149,7 +149,7 @@ async function spin(message, work, opts = {}) {
149
149
  }
150
150
 
151
151
  // src/program.ts
152
- import { Command as Command77 } from "commander";
152
+ import { Command as Command69 } from "commander";
153
153
 
154
154
  // ../shared/src/version.ts
155
155
  import { createRequire } from "module";
@@ -164,7 +164,7 @@ function versionOf(srcFileUrl, injected) {
164
164
  }
165
165
 
166
166
  // src/version.ts
167
- var VERSION = versionOf(import.meta.url, true ? "0.5.43" : void 0);
167
+ var VERSION = versionOf(import.meta.url, true ? "0.5.44" : void 0);
168
168
 
169
169
  // src/commands/vm/index.ts
170
170
  import { Command as Command37 } from "commander";
@@ -205,7 +205,7 @@ function paths(home = kvboxHome()) {
205
205
  tls: join(home, "tls"),
206
206
  tlsKey: join(home, "tls", "key.pem"),
207
207
  tlsCert: join(home, "tls", "cert.pem"),
208
- /** The host's WireGuard tunnel to its relay (`kvbox server relay`, #50): the conf net-setup.sh installs for wg-quick. Mode 600. */
208
+ /** The host's WireGuard tunnel to its relay (`kvbox-server relay`, #50): the conf net-setup.sh installs for wg-quick. Mode 600. */
209
209
  relay: join(home, "relay"),
210
210
  relayConf: join(home, "relay", "kvbox.conf"),
211
211
  bin: join(home, "bin"),
@@ -1048,7 +1048,7 @@ var SshCertResponseSchema = z2.object({
1048
1048
  });
1049
1049
  var SshCaResponseSchema = z2.object({
1050
1050
  publicKey: z2.string(),
1051
- /** CAs replaced by `ca rotate` (#55), newest first; a box still holding one of these has not had `kvbox server trust-ca` run on its host. */
1051
+ /** CAs replaced by `ca rotate` (#55), newest first; a box still holding one of these has not had `kvbox-server trust-ca` run on its host. */
1052
1052
  retired: z2.array(z2.object({ publicKey: z2.string(), retiredAt: z2.string() })).optional()
1053
1053
  });
1054
1054
  var HostSshCaResponseSchema = z2.object({
@@ -1080,7 +1080,7 @@ var HostJoinRequestSchema = z2.object({
1080
1080
  url: z2.string().url(),
1081
1081
  fingerprint: z2.string().regex(/^([0-9A-F]{2}:){31}[0-9A-F]{2}$/),
1082
1082
  publicAddress: z2.string().min(1),
1083
- /** Where the host is (`kvbox server join --country`): a code or an English name. */
1083
+ /** Where the host is (`kvbox-server join --country`): a code or an English name. */
1084
1084
  country: z2.string().optional()
1085
1085
  });
1086
1086
  var HostJoinResponseSchema = z2.object({
@@ -1139,7 +1139,7 @@ function groupWithMember(gid, user, groupFile) {
1139
1139
  return void 0;
1140
1140
  }
1141
1141
 
1142
- // src/systemd.ts
1142
+ // ../shared/src/systemd.ts
1143
1143
  import { spawnSync } from "child_process";
1144
1144
  import { readFileSync as readFileSync2 } from "fs";
1145
1145
  import { resolve } from "path";
@@ -1163,9 +1163,6 @@ function unitActive() {
1163
1163
  const res = spawnSync("systemctl", ["is-active", UNIT], { encoding: "utf8" });
1164
1164
  return (res.stdout ?? "").trim() === "active";
1165
1165
  }
1166
- function startsAtBoot(p) {
1167
- return hasUnitFor(p) && spawnSync("systemctl", ["is-enabled", "--quiet", UNIT]).status === 0;
1168
- }
1169
1166
 
1170
1167
  // src/client.ts
1171
1168
  var ORG_SLUG_RE = /^[a-z0-9][a-z0-9._-]{0,31}$/;
@@ -1224,7 +1221,7 @@ var ServerClient = class {
1224
1221
  await spin("starting kvbox-server\u2026", startLocalServer(paths(), 5e3));
1225
1222
  return this.call(method, path, schema, body, org, timeoutMs);
1226
1223
  }
1227
- throw new KvboxError(`kvbox-server is not running (${String(code)}); start it with: kvbox server start`);
1224
+ throw new KvboxError(`kvbox-server is not running (${String(code)}); start it with: kvbox-server start -d`);
1228
1225
  }
1229
1226
  throw new KvboxError(cloudDown(this.target.url, String(code)));
1230
1227
  }
@@ -1581,10 +1578,13 @@ async function checkDirect(ep) {
1581
1578
  }
1582
1579
  var NOT_A_HOST_HINT = "kvbox-server is not installed, so this machine is not a kvbox host. Set it up with install-server.sh, or log in to the cloud with: kvbox login";
1583
1580
  async function lastErrorLine(logPath, from = 0) {
1584
- const { readFile: readFile9 } = await import("fs/promises");
1585
- const text2 = (await readFile9(logPath).catch(() => Buffer.alloc(0))).subarray(from).toString("utf8");
1586
- const lines = text2.trimEnd().split("\n").slice(-20).reverse();
1587
- return lines.find((l) => l.startsWith("error: "))?.slice("error: ".length);
1581
+ const { readFile: readFile8 } = await import("fs/promises");
1582
+ const text2 = (await readFile8(logPath).catch(() => Buffer.alloc(0))).subarray(from).toString("utf8");
1583
+ for (const line of text2.trimEnd().split("\n").slice(-20).reverse()) {
1584
+ const m = /^(?:\[[^\]]*\])?\[?error\]?: (.*)$/.exec(line);
1585
+ if (m?.[1] !== void 0) return m[1];
1586
+ }
1587
+ return void 0;
1588
1588
  }
1589
1589
  async function startLocalServer(p = paths(), timeoutMs = 5e3) {
1590
1590
  await mkdir2(p.home, { recursive: true });
@@ -3291,199 +3291,14 @@ var vmCommand = new Command37("vm").enablePositionalOptions().description("manag
3291
3291
  for (const cmd of vmCommand.commands) if (cmd !== proxyCommand && cmd !== hookCommand && cmd !== backupCommand) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
3292
3292
  var vmAliases = [newCommand, lsCommand, getCommand, connectCommand, execCommand, stopCommand, startCommand, pauseCommand, resumeCommand, hibernateCommand, wakeCommand, rmCommand3, claimCommand];
3293
3293
 
3294
- // src/commands/server/index.ts
3295
- import { Command as Command45 } from "commander";
3296
-
3297
- // src/commands/server/join.ts
3298
- import { Command as Command38 } from "commander";
3299
-
3300
- // src/commands/server/daemon.ts
3301
- import { spawn as spawn4 } from "child_process";
3302
- import { readFile as readFile4 } from "fs/promises";
3303
- import { setTimeout as sleep3 } from "timers/promises";
3304
- async function runningPid(p = paths()) {
3305
- let pid;
3306
- try {
3307
- pid = Number.parseInt(await readFile4(p.serverPid, "utf8"), 10);
3308
- } catch {
3309
- return null;
3310
- }
3311
- return alive(pid) ? pid : null;
3312
- }
3313
- function alive(pid) {
3314
- try {
3315
- process.kill(pid, 0);
3316
- return true;
3317
- } catch {
3318
- return false;
3319
- }
3320
- }
3321
- async function stopLocalServer(pid, timeoutMs = 1e4) {
3322
- process.kill(pid, "SIGTERM");
3323
- const deadline = Date.now() + timeoutMs;
3324
- while (alive(pid)) {
3325
- if (Date.now() > deadline) throw new KvboxError(`kvbox-server (pid ${pid}) did not stop within ${timeoutMs / 1e3}s`);
3326
- await sleep3(100);
3327
- }
3328
- }
3329
- async function restartLocalServer(p = paths()) {
3330
- const pid = await runningPid(p);
3331
- if (pid !== null) await stopLocalServer(pid);
3332
- return (await startLocalServer(p)).pid;
3333
- }
3334
- function runKvboxServer(args) {
3335
- return new Promise((resolve3, reject) => {
3336
- const child = spawn4("kvbox-server", args, { stdio: ["ignore", "pipe", "pipe"] });
3337
- let out = "";
3338
- let err = "";
3339
- child.stdout.on("data", (chunk) => out += chunk.toString());
3340
- child.stderr.on("data", (chunk) => err += chunk.toString());
3341
- child.once("error", (e) => {
3342
- reject(new KvboxError(e.code === "ENOENT" ? NOT_A_HOST_HINT : `could not run kvbox-server: ${e.message}`));
3343
- });
3344
- child.once("close", (code) => {
3345
- if (code === 0) resolve3(out.trimEnd());
3346
- else reject(new KvboxError(err.trim().replace(/^error: /, "") || `kvbox-server ${args[0] ?? ""} exited with code ${String(code)}`, code === 2 ? 2 : 1));
3347
- });
3348
- });
3349
- }
3350
-
3351
- // src/commands/server/join.ts
3352
- var joinCommand = new Command38("join").description("put this machine behind a control plane (needs a one-time token minted there) and restart its server").argument("<control-plane-url>", "the control plane, e.g. https://api.kvbox.sh").requiredOption("--token <token>", "one-time join token from the control plane").option("--advertise <host-or-ip>", "address the control plane reaches this machine at (default: its default-route address)").option("--name <name>", "how the control plane lists this machine (default: hostname)").option("--country <country>", "where this machine is, a name or a code (romania, US); kvbox new --country places boxes by it").action(async (url, opts) => {
3353
- const args = ["join", url, "--token", opts.token];
3354
- if (opts.advertise !== void 0) args.push("--advertise", opts.advertise);
3355
- if (opts.name !== void 0) args.push("--name", opts.name);
3356
- if (opts.country !== void 0) args.push("--country", opts.country);
3357
- for (const line of (await runKvboxServer(args)).split("\n")) info(line);
3358
- const pid = await spin("restarting kvbox-server\u2026", restartLocalServer(paths()));
3359
- info(`kvbox-server restarted (pid ${pid}); it answers the control plane now`);
3360
- });
3361
-
3362
- // src/commands/server/leave.ts
3363
- import { Command as Command39 } from "commander";
3364
- var leaveCommand = new Command39("leave").description("take this machine out from behind its control plane and restart its server").action(async () => {
3365
- const p = paths();
3366
- for (const line of (await runKvboxServer(["leave"])).split("\n")) info(line);
3367
- if (await runningPid(p) === null) return;
3368
- const pid = await spin("restarting kvbox-server\u2026", restartLocalServer(p));
3369
- info(`kvbox-server restarted (pid ${pid}); only this machine talks to it now`);
3370
- });
3371
-
3372
- // src/commands/server/relay.ts
3373
- import { Command as Command40 } from "commander";
3374
- var relayCommand = new Command40("relay").description("reach the internet through a relay (paste what `kvbox-relay add` printed on the relay VM); `off` takes the tunnel down").argument("<join-string>", "the line `kvbox-relay add` printed, or `off`").action(async (joinString) => {
3375
- for (const line of (await runKvboxServer(["relay", joinString])).split("\n")) info(line);
3376
- });
3377
-
3378
- // src/commands/server/start.ts
3379
- import { Command as Command41 } from "commander";
3380
- var startCommand2 = new Command41("start").description("start the local kvbox-server in the background").action(async (_opts, cmd) => {
3381
- const client = await clientFor({ ...cmd.optsWithGlobals(), local: true }, { autoStart: false });
3382
- try {
3383
- const health = await client.health();
3384
- info(`kvbox-server ${health.version} is already running (pid ${health.pid})`);
3385
- return;
3386
- } catch {
3387
- } finally {
3388
- await client.close();
3389
- }
3390
- const { pid, socketPath, viaGroup } = await startLocalServer(paths());
3391
- info(`kvbox-server started (pid ${pid}), listening on ${socketPath}`);
3392
- if (viaGroup !== void 0) info(`started through the ${viaGroup} group, which this shell does not have yet (log out and back in to get it)`);
3393
- });
3394
-
3395
- // src/commands/server/status.ts
3396
- import { Command as Command42 } from "commander";
3397
- var statusCommand = new Command42("status").description("show whether this machine's server is running, its control plane and which base image new boxes get").option("--json", "print as JSON").action(async (opts, cmd) => {
3398
- const client = await clientFor({ ...cmd.optsWithGlobals(), local: true });
3399
- try {
3400
- const health = await client.health();
3401
- const atBoot = startsAtBoot(paths());
3402
- if (opts.json) json({ ...health, startsAtBoot: atBoot });
3403
- else {
3404
- info(`kvbox-server ${health.version} running, pid ${health.pid}`);
3405
- info(atBoot ? "starts at boot: yes, and brings back the boxes that were running" : "starts at boot: no (install-server.sh sets that up)");
3406
- const r = health.recovery;
3407
- if (r) {
3408
- if (r.booted.length > 0) info(`after the last restart it booted again: ${r.booted.join(", ")}`);
3409
- if (r.leftStopped.length > 0) info(`left stopped (were in standby, their memory was lost): ${r.leftStopped.join(", ")}`);
3410
- for (const f of r.failed) info(`did not come back: ${f.box} (${f.error})`);
3411
- }
3412
- if (health.controlPlane) info(`control plane: ${health.controlPlane.name} at ${health.controlPlane.url}, this host answers it on ${health.controlPlane.hostUrl}`);
3413
- else info("control plane: none (kvbox server join <url> --token <token> puts this machine behind one)");
3414
- if (health.relay) {
3415
- info(`relay: ${health.relay.name} lends this machine ${health.relay.publicIp} (tunnel to ${health.relay.endpoint})`);
3416
- if (health.relay.restarts && health.relay.lastRestartAt) {
3417
- info(`the tunnel stopped carrying traffic and was redialed ${health.relay.restarts} time(s) since the server started, last at ${health.relay.lastRestartAt}`);
3418
- }
3419
- }
3420
- if (health.base === null) info("base image: none usable yet (run install-server.sh)");
3421
- else info(`base image: ${health.base} (what kvbox new uses; kvbox vm update <box> moves an older box onto it)`);
3422
- }
3423
- } finally {
3424
- await client.close();
3425
- }
3426
- });
3427
-
3428
- // src/commands/server/stop.ts
3429
- import { Command as Command43 } from "commander";
3430
- var stopCommand2 = new Command43("stop").description("stop the local server (running boxes are not affected)").action(async () => {
3431
- const pid = await runningPid(paths());
3432
- if (pid === null) throw new KvboxError("kvbox-server is not running");
3433
- await stopLocalServer(pid);
3434
- info(`kvbox-server stopped (pid ${pid})`);
3435
- });
3436
-
3437
- // src/commands/server/trust-ca.ts
3438
- import { Command as Command44 } from "commander";
3439
- var trustCaCommand = new Command44("trust-ca").description("make every cloud box on this machine trust a new SSH CA (after `ca rotate` on the control plane)").argument("[public-key]", "the CA public key (or its cert-authority line); or --from-cloud").option("--from-cloud", "ask the control plane this host joined for its current CA, show the fingerprint, then ask").option("-y, --yes", "do not ask for confirmation").option("--json", "print the report as JSON").action(async (publicKey, opts, cmd) => {
3440
- if (publicKey === void 0 && !opts.fromCloud) throw new KvboxError("give the CA public key, or --from-cloud to fetch it from the control plane this host joined");
3441
- if (publicKey !== void 0 && opts.fromCloud) throw new KvboxError("either a public key or --from-cloud, not both");
3442
- const client = await clientFor({ ...cmd.optsWithGlobals(), local: true });
3443
- try {
3444
- let key = publicKey;
3445
- if (key === void 0) {
3446
- const ca = await client.cloudCa();
3447
- info(`${ca.controlPlane} says its SSH CA is ${ca.fingerprint}`);
3448
- if (!await confirm(`make every cloud box on this machine trust it (in place of the CA it trusts now)?`, opts.yes ?? false)) {
3449
- throw new KvboxError("cancelled", 130);
3450
- }
3451
- key = ca.publicKey;
3452
- }
3453
- const report = await client.trustCa({ publicKey: key });
3454
- if (opts.json) json(report);
3455
- else describeReport(report);
3456
- } finally {
3457
- await client.close();
3458
- }
3459
- });
3460
- var WHEN = {
3461
- start: "is stopped: it trusts the CA from its next start",
3462
- wake: "is hibernated: it trusts the CA from its next wake",
3463
- resume: "is in standby: it trusts the CA from its next resume",
3464
- later: "is running but could not take it now; it trusts the CA from its next stop and start"
3465
- };
3466
- function describeReport(report) {
3467
- info(`CA ${report.fingerprint}`);
3468
- for (const box of report.updated) info(`box ${box} now trusts the CA`);
3469
- for (const p of report.pending) info(`box ${p.box} ${WHEN[p.when]}${p.why ? ` (${p.why})` : ""}`);
3470
- for (const f of report.failed) warn(`box ${f.box}: ${f.error}`);
3471
- const parts = [`${report.updated.length} box(es) updated now`, `${report.pending.length} pending`, `${report.failed.length} failed`];
3472
- if (report.local > 0) parts.push(`${report.local} local box(es) untouched (they trust this host's key only)`);
3473
- info(parts.join(", "));
3474
- }
3475
-
3476
- // src/commands/server/index.ts
3477
- var serverCommand = new Command45("server").description("run or manage the kvbox server").addCommand(startCommand2).addCommand(statusCommand).addCommand(stopCommand2).addCommand(joinCommand).addCommand(leaveCommand).addCommand(relayCommand).addCommand(trustCaCommand);
3478
-
3479
3294
  // src/commands/login.ts
3480
3295
  import { spawnSync as spawnSync3 } from "child_process";
3481
- import { mkdir as mkdir3, readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
3296
+ import { mkdir as mkdir3, readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
3482
3297
  import { hostname as osHostname } from "os";
3483
3298
  import { createInterface as createInterface2 } from "readline/promises";
3484
3299
  import { Writable } from "stream";
3485
- import { Command as Command46 } from "commander";
3486
- var loginCommand = new Command46("login").description("log in to the kvbox cloud (or your own control plane) and target it from now on").argument("[url]", `control plane URL (default: ${DEFAULT_CLOUD_URL})`).option("-e, --email <email>", "account email (prompted otherwise)").option("--password-stdin", "read the password from the first line of stdin (for scripts)").action(async (urlArg, opts) => {
3300
+ import { Command as Command38 } from "commander";
3301
+ var loginCommand = new Command38("login").description("log in to the kvbox cloud (or your own control plane) and target it from now on").argument("[url]", `control plane URL (default: ${DEFAULT_CLOUD_URL})`).option("-e, --email <email>", "account email (prompted otherwise)").option("--password-stdin", "read the password from the first line of stdin (for scripts)").action(async (urlArg, opts) => {
3487
3302
  const url = normalizeUrl(urlArg ?? DEFAULT_CLOUD_URL);
3488
3303
  const creds = await readCredentials(opts);
3489
3304
  const session = await runLogin(url, creds, paths());
@@ -3524,10 +3339,10 @@ async function runLogin(url, creds, p = paths(), hostname = osHostname()) {
3524
3339
  }
3525
3340
  async function ensureSshKey(p = paths(), hostname = osHostname()) {
3526
3341
  const pubPath = `${p.sshKey}.pub`;
3527
- const pub = await readFile5(pubPath, "utf8").catch(() => null);
3342
+ const pub = await readFile4(pubPath, "utf8").catch(() => null);
3528
3343
  if (pub !== null) return pub.trim();
3529
3344
  await mkdir3(p.ssh, { recursive: true, mode: 448 });
3530
- const havePrivate = await readFile5(p.sshKey).then(() => true, () => false);
3345
+ const havePrivate = await readFile4(p.sshKey).then(() => true, () => false);
3531
3346
  const args = havePrivate ? ["-y", "-f", p.sshKey] : ["-q", "-t", "ed25519", "-N", "", "-C", `kvbox@${hostname}`, "-f", p.sshKey];
3532
3347
  const res = spawnSync3("ssh-keygen", args, { stdio: ["ignore", "pipe", "pipe"], encoding: "utf8" });
3533
3348
  if (res.error) {
@@ -3536,7 +3351,7 @@ async function ensureSshKey(p = paths(), hostname = osHostname()) {
3536
3351
  }
3537
3352
  if (res.status !== 0) throw new KvboxError(`ssh-keygen failed: ${res.stderr.trim()}`);
3538
3353
  if (havePrivate) await writeFile3(pubPath, res.stdout.trim() + "\n");
3539
- return (await readFile5(pubPath, "utf8")).trim();
3354
+ return (await readFile4(pubPath, "utf8")).trim();
3540
3355
  }
3541
3356
  async function prompt(question, io) {
3542
3357
  const rl = createInterface2({ input: io.input, output: io.output });
@@ -3563,8 +3378,8 @@ async function firstLine(stream) {
3563
3378
  }
3564
3379
 
3565
3380
  // src/commands/logout.ts
3566
- import { Command as Command47 } from "commander";
3567
- var logoutCommand = new Command47("logout").description("log out of the control plane; commands target this machine's kvbox-server again").action(async () => {
3381
+ import { Command as Command39 } from "commander";
3382
+ var logoutCommand = new Command39("logout").description("log out of the control plane; commands target this machine's kvbox-server again").action(async () => {
3568
3383
  const p = paths();
3569
3384
  const session = await readSession(p).catch(() => null);
3570
3385
  switch (await runLogout(p)) {
@@ -3601,8 +3416,8 @@ async function runLogout(p = paths()) {
3601
3416
  }
3602
3417
 
3603
3418
  // src/commands/whoami.ts
3604
- import { Command as Command48 } from "commander";
3605
- var whoamiCommand = new Command48("whoami").description("show which account and control plane commands target (or local mode)").option("--json", "print as JSON").action(async (opts) => {
3419
+ import { Command as Command40 } from "commander";
3420
+ var whoamiCommand = new Command40("whoami").description("show which account and control plane commands target (or local mode)").option("--json", "print as JSON").action(async (opts) => {
3606
3421
  const session = await readSession();
3607
3422
  if (opts.json) {
3608
3423
  json(session ? { user: session.user, url: session.url, sshCertExpires: session.sshCertExpires ?? null } : null);
@@ -3618,11 +3433,11 @@ function describeSession(session) {
3618
3433
  }
3619
3434
 
3620
3435
  // src/commands/snapshots/index.ts
3621
- import { Command as Command52 } from "commander";
3436
+ import { Command as Command44 } from "commander";
3622
3437
 
3623
3438
  // src/commands/snapshots/ls.ts
3624
- import { Command as Command49 } from "commander";
3625
- var lsCommand5 = new Command49("ls").description("list snapshots (yours and your orgs'; --org <slug> for one org)").option("-a, --all", "every snapshot on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
3439
+ import { Command as Command41 } from "commander";
3440
+ var lsCommand5 = new Command41("ls").description("list snapshots (yours and your orgs'; --org <slug> for one org)").option("-a, --all", "every snapshot on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
3626
3441
  const client = await clientFor(cmd.optsWithGlobals());
3627
3442
  try {
3628
3443
  const cloud = client.target.kind === "cloud";
@@ -3653,8 +3468,8 @@ var lsCommand5 = new Command49("ls").description("list snapshots (yours and your
3653
3468
  });
3654
3469
 
3655
3470
  // src/commands/snapshots/new.ts
3656
- import { Command as Command50 } from "commander";
3657
- var newCommand2 = new Command50("new").description("freeze a running box (memory + disk) into a snapshot; the box keeps running").argument("<box>", "box name").argument("<name>", "snapshot name").option("--replace", "retake a snapshot that exists under this name; the old one stays until the new one is complete").option("--json", "print the snapshot as JSON").action(async (box, name, opts, cmd) => {
3471
+ import { Command as Command42 } from "commander";
3472
+ var newCommand2 = new Command42("new").description("freeze a running box (memory + disk) into a snapshot; the box keeps running").argument("<box>", "box name").argument("<name>", "snapshot name").option("--replace", "retake a snapshot that exists under this name; the old one stays until the new one is complete").option("--json", "print the snapshot as JSON").action(async (box, name, opts, cmd) => {
3658
3473
  const client = await clientFor(cmd.optsWithGlobals());
3659
3474
  try {
3660
3475
  const req = { box, name, ...opts.replace ? { replace: true } : {} };
@@ -3667,8 +3482,8 @@ var newCommand2 = new Command50("new").description("freeze a running box (memory
3667
3482
  });
3668
3483
 
3669
3484
  // src/commands/snapshots/rm.ts
3670
- import { Command as Command51 } from "commander";
3671
- var rmCommand4 = new Command51("rm").description("delete a snapshot (boxes made from it are not affected)").argument("<name>", "snapshot name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
3485
+ import { Command as Command43 } from "commander";
3486
+ var rmCommand4 = new Command43("rm").description("delete a snapshot (boxes made from it are not affected)").argument("<name>", "snapshot name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
3672
3487
  if (!await confirm(`Delete snapshot ${name}?`, opts.yes ?? false)) {
3673
3488
  info("cancelled");
3674
3489
  process.exitCode = 1;
@@ -3684,14 +3499,14 @@ var rmCommand4 = new Command51("rm").description("delete a snapshot (boxes made
3684
3499
  });
3685
3500
 
3686
3501
  // src/commands/snapshots/index.ts
3687
- var snapshotsCommand = new Command52("snapshots").aliases(["snapshot", "snap"]).description("freeze running boxes into snapshots and manage them").addCommand(newCommand2).addCommand(lsCommand5).addCommand(rmCommand4);
3502
+ var snapshotsCommand = new Command44("snapshots").aliases(["snapshot", "snap"]).description("freeze running boxes into snapshots and manage them").addCommand(newCommand2).addCommand(lsCommand5).addCommand(rmCommand4);
3688
3503
  for (const cmd of snapshotsCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
3689
3504
 
3690
3505
  // src/commands/org/index.ts
3691
- import { Command as Command58 } from "commander";
3506
+ import { Command as Command50 } from "commander";
3692
3507
 
3693
3508
  // src/commands/org/ls.ts
3694
- import { Command as Command53 } from "commander";
3509
+ import { Command as Command45 } from "commander";
3695
3510
 
3696
3511
  // src/commands/org/context.ts
3697
3512
  var NOT_LOGGED_IN = "orgs live on the control plane: kvbox login first";
@@ -3711,7 +3526,7 @@ function orgFor(opts, target) {
3711
3526
  }
3712
3527
 
3713
3528
  // src/commands/org/ls.ts
3714
- var lsCommand6 = new Command53("ls").description("list the orgs you belong to and your role in each").option("--json", "print as JSON").action(async (opts, cmd) => {
3529
+ var lsCommand6 = new Command45("ls").description("list the orgs you belong to and your role in each").option("--json", "print as JSON").action(async (opts, cmd) => {
3715
3530
  const client = await cloudClientFor(cmd.optsWithGlobals());
3716
3531
  try {
3717
3532
  const orgs = await client.listOrgs();
@@ -3733,8 +3548,8 @@ function orgRows(orgs) {
3733
3548
  }
3734
3549
 
3735
3550
  // src/commands/org/members.ts
3736
- import { Command as Command54, Option as Option4 } from "commander";
3737
- var lsCommand7 = new Command54("ls").description("list an org's members and their roles").option("-o, --org <slug>", "the org (or --org before the command)").option("--json", "print as JSON").action(async (opts, cmd) => {
3551
+ import { Command as Command46, Option as Option4 } from "commander";
3552
+ var lsCommand7 = new Command46("ls").description("list an org's members and their roles").option("-o, --org <slug>", "the org (or --org before the command)").option("--json", "print as JSON").action(async (opts, cmd) => {
3738
3553
  const client = await cloudClientFor(cmd.optsWithGlobals());
3739
3554
  try {
3740
3555
  const org = await client.getOrg(orgFor(opts, client.target));
@@ -3748,7 +3563,7 @@ var lsCommand7 = new Command54("ls").description("list an org's members and thei
3748
3563
  await client.close();
3749
3564
  }
3750
3565
  });
3751
- var addCommand2 = new Command54("add").description("add a user to an org (admins and owners; only an owner can add an owner)").argument("<user>", "their username").addOption(new Option4("-r, --role <role>", "their role").choices(ORG_ROLES).default("member")).option("-o, --org <slug>", "the org (or --org before the command)").action(async (user, opts, cmd) => {
3566
+ var addCommand2 = new Command46("add").description("add a user to an org (admins and owners; only an owner can add an owner)").argument("<user>", "their username").addOption(new Option4("-r, --role <role>", "their role").choices(ORG_ROLES).default("member")).option("-o, --org <slug>", "the org (or --org before the command)").action(async (user, opts, cmd) => {
3752
3567
  const client = await cloudClientFor(cmd.optsWithGlobals());
3753
3568
  try {
3754
3569
  const slug = orgFor(opts, client.target);
@@ -3758,7 +3573,7 @@ var addCommand2 = new Command54("add").description("add a user to an org (admins
3758
3573
  await client.close();
3759
3574
  }
3760
3575
  });
3761
- var rmCommand5 = new Command54("rm").description("remove a member (or leave: remove yourself)").argument("<user>", "their username").option("-o, --org <slug>", "the org (or --org before the command)").option("-y, --yes", "do not ask for confirmation").action(async (user, opts, cmd) => {
3576
+ var rmCommand5 = new Command46("rm").description("remove a member (or leave: remove yourself)").argument("<user>", "their username").option("-o, --org <slug>", "the org (or --org before the command)").option("-y, --yes", "do not ask for confirmation").action(async (user, opts, cmd) => {
3762
3577
  const client = await cloudClientFor(cmd.optsWithGlobals());
3763
3578
  try {
3764
3579
  const slug = orgFor(opts, client.target);
@@ -3774,11 +3589,11 @@ var rmCommand5 = new Command54("rm").description("remove a member (or leave: rem
3774
3589
  await client.close();
3775
3590
  }
3776
3591
  });
3777
- var membersCommand = new Command54("members").description("who is in an org and what they may do").addCommand(lsCommand7).addCommand(addCommand2).addCommand(rmCommand5);
3592
+ var membersCommand = new Command46("members").description("who is in an org and what they may do").addCommand(lsCommand7).addCommand(addCommand2).addCommand(rmCommand5);
3778
3593
 
3779
3594
  // src/commands/org/new.ts
3780
- import { Command as Command55 } from "commander";
3781
- var newCommand3 = new Command55("new").description("create an org; you become its owner (the slug is permanent, the name is not)").argument("<slug>", "the org's slug: lowercase, like a username (acme)").option("-n, --name <name>", "display name (default: the slug)").option("--json", "print the org as JSON").action(async (slug, opts, cmd) => {
3595
+ import { Command as Command47 } from "commander";
3596
+ var newCommand3 = new Command47("new").description("create an org; you become its owner (the slug is permanent, the name is not)").argument("<slug>", "the org's slug: lowercase, like a username (acme)").option("-n, --name <name>", "display name (default: the slug)").option("--json", "print the org as JSON").action(async (slug, opts, cmd) => {
3782
3597
  const client = await cloudClientFor(cmd.optsWithGlobals());
3783
3598
  try {
3784
3599
  const org = await client.createOrg({ slug, name: opts.name ?? slug });
@@ -3794,8 +3609,8 @@ var newCommand3 = new Command55("new").description("create an org; you become it
3794
3609
  });
3795
3610
 
3796
3611
  // src/commands/org/rm.ts
3797
- import { Command as Command56 } from "commander";
3798
- var rmCommand6 = new Command56("rm").description("delete an org (owners only; remove its boxes and snapshots first)").argument("<slug>", "the org").option("-y, --yes", "do not ask for confirmation").action(async (slug, opts, cmd) => {
3612
+ import { Command as Command48 } from "commander";
3613
+ var rmCommand6 = new Command48("rm").description("delete an org (owners only; remove its boxes and snapshots first)").argument("<slug>", "the org").option("-y, --yes", "do not ask for confirmation").action(async (slug, opts, cmd) => {
3799
3614
  if (!await confirm(`Delete org ${slug}? Its members lose access; its slug stays taken.`, opts.yes ?? false)) {
3800
3615
  info("cancelled");
3801
3616
  process.exitCode = 1;
@@ -3811,8 +3626,8 @@ var rmCommand6 = new Command56("rm").description("delete an org (owners only; re
3811
3626
  });
3812
3627
 
3813
3628
  // src/commands/org/role.ts
3814
- import { Argument, Command as Command57 } from "commander";
3815
- var roleCommand = new Command57("role").description("change a member's role (owners only)").argument("<user>", "their username").addArgument(new Argument("<role>", "owner, admin or member").choices(ORG_ROLES)).option("-o, --org <slug>", "the org (default: the current context)").action(async (user, role, opts, cmd) => {
3629
+ import { Argument, Command as Command49 } from "commander";
3630
+ var roleCommand = new Command49("role").description("change a member's role (owners only)").argument("<user>", "their username").addArgument(new Argument("<role>", "owner, admin or member").choices(ORG_ROLES)).option("-o, --org <slug>", "the org (default: the current context)").action(async (user, role, opts, cmd) => {
3816
3631
  const client = await cloudClientFor(cmd.optsWithGlobals());
3817
3632
  try {
3818
3633
  const slug = orgFor(opts, client.target);
@@ -3824,10 +3639,10 @@ var roleCommand = new Command57("role").description("change a member's role (own
3824
3639
  });
3825
3640
 
3826
3641
  // src/commands/org/index.ts
3827
- var orgCommand = new Command58("org").description("orgs: shared slugs that own boxes, with owners, admins and members").addCommand(lsCommand6).addCommand(newCommand3).addCommand(membersCommand).addCommand(roleCommand).addCommand(rmCommand6);
3642
+ var orgCommand = new Command50("org").description("orgs: shared slugs that own boxes, with owners, admins and members").addCommand(lsCommand6).addCommand(newCommand3).addCommand(membersCommand).addCommand(roleCommand).addCommand(rmCommand6);
3828
3643
 
3829
3644
  // src/commands/usage.ts
3830
- import { Command as Command59 } from "commander";
3645
+ import { Command as Command51 } from "commander";
3831
3646
 
3832
3647
  // ../shared/src/usage.ts
3833
3648
  import { z as z4 } from "zod";
@@ -3866,7 +3681,7 @@ function sumUsage(items, pricing) {
3866
3681
  }
3867
3682
 
3868
3683
  // src/commands/usage.ts
3869
- var usageCommand2 = new Command59("usage").description("what your boxes and volumes used this month (or --since/--until): running time, vCPU-h, RAM and disk GiB-h, cost").option("--since <date>", "count from this date, e.g. 2026-10-01 (default: the 1st of this month)").option("--until <date>", "count up to this date (default: now)").option("--org <slug>", "one org's boxes only").option("-a, --all", "every box on the platform (platform admins only)").option("--by-user", "one line per user who made the boxes (e.g. who spent what in --org)").option("--json", "print as JSON").action(async (opts, cmd) => {
3684
+ var usageCommand2 = new Command51("usage").description("what your boxes and volumes used this month (or --since/--until): running time, vCPU-h, RAM and disk GiB-h, cost").option("--since <date>", "count from this date, e.g. 2026-10-01 (default: the 1st of this month)").option("--until <date>", "count up to this date (default: now)").option("--org <slug>", "one org's boxes only").option("-a, --all", "every box on the platform (platform admins only)").option("--by-user", "one line per user who made the boxes (e.g. who spent what in --org)").option("--json", "print as JSON").action(async (opts, cmd) => {
3870
3685
  for (const [name, value] of [
3871
3686
  ["since", opts.since],
3872
3687
  ["until", opts.until]
@@ -4012,8 +3827,8 @@ function userRows(r) {
4012
3827
  }
4013
3828
 
4014
3829
  // src/commands/credit.ts
4015
- import { Command as Command60 } from "commander";
4016
- var creditCommand = new Command60("credit").description("the prepaid credit left on your account and on each of your orgs").option("--org <slug>", "one org only").option("--json", "print as JSON").action(async (opts, cmd) => {
3830
+ import { Command as Command52 } from "commander";
3831
+ var creditCommand = new Command52("credit").description("the prepaid credit left on your account and on each of your orgs").option("--org <slug>", "one org only").option("--json", "print as JSON").action(async (opts, cmd) => {
4017
3832
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
4018
3833
  try {
4019
3834
  if (client.target.kind === "local") throw new KvboxError("credit lives on the control plane: kvbox login first");
@@ -4041,17 +3856,17 @@ function creditRow(b, me2) {
4041
3856
  }
4042
3857
 
4043
3858
  // src/commands/deploy/index.ts
4044
- import { access as access4, readFile as readFile8 } from "fs/promises";
3859
+ import { access as access4, readFile as readFile7 } from "fs/promises";
4045
3860
  import { basename, resolve as resolve2 } from "path";
4046
- import { Command as Command61, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
3861
+ import { Command as Command53, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
4047
3862
 
4048
3863
  // src/commands/deploy/config.ts
4049
- import { readFile as readFile7, writeFile as writeFile4 } from "fs/promises";
3864
+ import { readFile as readFile6, writeFile as writeFile4 } from "fs/promises";
4050
3865
  import { join as join6 } from "path";
4051
3866
  import { z as z5 } from "zod";
4052
3867
 
4053
3868
  // src/commands/deploy/templates/docker.ts
4054
- import { readFile as readFile6 } from "fs/promises";
3869
+ import { readFile as readFile5 } from "fs/promises";
4055
3870
  import { join as join2 } from "path";
4056
3871
 
4057
3872
  // src/commands/deploy/templates/server.ts
@@ -4150,7 +3965,7 @@ var dockerTemplate = {
4150
3965
  },
4151
3966
  /** No local build: the box does it. The Dockerfile is read for its EXPOSE port only. */
4152
3967
  async build(ctx) {
4153
- const dockerfile = await readFile6(join2(ctx.dir, "Dockerfile"), "utf8").catch(() => void 0);
3968
+ const dockerfile = await readFile5(join2(ctx.dir, "Dockerfile"), "utf8").catch(() => void 0);
4154
3969
  if (dockerfile === void 0) throw new KvboxError(`${ctx.dir}: no Dockerfile; the Docker template builds the image from it`);
4155
3970
  const containerPort = exposedPort(dockerfile);
4156
3971
  return { outDir: ctx.dir, exclude: ["node_modules", ".git"], pm: "npm", what: "the source", ...containerPort !== void 0 ? { containerPort } : {} };
@@ -4257,7 +4072,7 @@ var nodeTemplate = {
4257
4072
  };
4258
4073
 
4259
4074
  // src/commands/deploy/templates/react.ts
4260
- import { spawn as spawn5 } from "child_process";
4075
+ import { spawn as spawn4 } from "child_process";
4261
4076
  import { access as access2 } from "fs/promises";
4262
4077
  import { join as join4 } from "path";
4263
4078
  var OUT_DIRS = ["dist", "build"];
@@ -4265,7 +4080,7 @@ async function runBuild(dir, pm) {
4265
4080
  const args = runScript(pm, "build");
4266
4081
  info(`${color.dim("$")} ${pm} ${args.join(" ")}`);
4267
4082
  const status2 = await new Promise((resolve3, reject) => {
4268
- const child = spawn5(pm, args, { cwd: dir, stdio: ["ignore", process.stderr, process.stderr], shell: process.platform === "win32" });
4083
+ const child = spawn4(pm, args, { cwd: dir, stdio: ["ignore", process.stderr, process.stderr], shell: process.platform === "win32" });
4269
4084
  child.once("error", (err) => reject(new KvboxError(`could not run ${pm}: ${err.message}`)));
4270
4085
  child.once("close", (code) => resolve3(code ?? 1));
4271
4086
  });
@@ -4382,7 +4197,7 @@ async function readConfig(dir) {
4382
4197
  const path = join6(dir, CONFIG_FILE);
4383
4198
  let raw;
4384
4199
  try {
4385
- raw = await readFile7(path, "utf8");
4200
+ raw = await readFile6(path, "utf8");
4386
4201
  } catch (err) {
4387
4202
  if (err.code === "ENOENT") return void 0;
4388
4203
  throw err;
@@ -4412,7 +4227,7 @@ function subdomainFor(name) {
4412
4227
  }
4413
4228
 
4414
4229
  // src/commands/deploy/ship.ts
4415
- import { spawn as spawn6 } from "child_process";
4230
+ import { spawn as spawn5 } from "child_process";
4416
4231
  import { readdir, stat as stat2 } from "fs/promises";
4417
4232
  import { join as join7 } from "path";
4418
4233
  var IMAGE_TOO_OLD = 3;
@@ -4434,8 +4249,8 @@ async function measure(dir, exclude = []) {
4434
4249
  return total;
4435
4250
  }
4436
4251
  async function ship(ep, dir, remote, exclude = []) {
4437
- const tar = spawn6("tar", ["-cf", "-", ...exclude.map((e) => `--exclude=${e}`), "-C", dir, "."], { stdio: ["ignore", "pipe", "pipe"] });
4438
- const ssh = spawn6("ssh", [...sshArgs(ep), remote], { stdio: ["pipe", "pipe", "pipe"] });
4252
+ const tar = spawn5("tar", ["-cf", "-", ...exclude.map((e) => `--exclude=${e}`), "-C", dir, "."], { stdio: ["ignore", "pipe", "pipe"] });
4253
+ const ssh = spawn5("ssh", [...sshArgs(ep), remote], { stdio: ["pipe", "pipe", "pipe"] });
4439
4254
  tar.stdout.pipe(ssh.stdin);
4440
4255
  const chunks = [];
4441
4256
  ssh.stdout.on("data", (c) => chunks.push(c));
@@ -4465,7 +4280,7 @@ async function ship(ep, dir, remote, exclude = []) {
4465
4280
  var shipping = { ship, measure, waitForSsh };
4466
4281
 
4467
4282
  // src/commands/deploy/index.ts
4468
- var deployCommand = new Command61("deploy").description("put the app in this directory (React, Next.js, a Node server, a Dockerfile or a static site) on a box with its own HTTPS address; redeploy by running it again").argument("[dir]", "the app's directory (default: the current one)").addOption(new Option5("-t, --template <template>", "what kind of app it is (detected from package.json and the directory when not given)").choices(TEMPLATE_IDS)).option("-n, --name <name>", "the box's name (default: the directory's name)").option("--sub <subdomain>", "its HTTPS name, https://<subdomain>.kvbox.app (default: the box's name)").addOption(new Option5("-s, --size <size>", "size of the box when it has to be made").choices(SIZE_NAMES)).option("--port <port>", "the box port of a Next.js app, Node server or container (default 3000; saved to kvbox.json)", parsePort).option("-y, --yes", "ask nothing: take the defaults for whatever the flags and kvbox.json leave open").option("--json", "print the result as JSON").option("--org <slug>", "deploy into this org's boxes (saved to kvbox.json)").action(async (dirArg, opts, cmd) => {
4283
+ var deployCommand = new Command53("deploy").description("put the app in this directory (React, Next.js, a Node server, a Dockerfile or a static site) on a box with its own HTTPS address; redeploy by running it again").argument("[dir]", "the app's directory (default: the current one)").addOption(new Option5("-t, --template <template>", "what kind of app it is (detected from package.json and the directory when not given)").choices(TEMPLATE_IDS)).option("-n, --name <name>", "the box's name (default: the directory's name)").option("--sub <subdomain>", "its HTTPS name, https://<subdomain>.kvbox.app (default: the box's name)").addOption(new Option5("-s, --size <size>", "size of the box when it has to be made").choices(SIZE_NAMES)).option("--port <port>", "the box port of a Next.js app, Node server or container (default 3000; saved to kvbox.json)", parsePort).option("-y, --yes", "ask nothing: take the defaults for whatever the flags and kvbox.json leave open").option("--json", "print the result as JSON").option("--org <slug>", "deploy into this org's boxes (saved to kvbox.json)").action(async (dirArg, opts, cmd) => {
4469
4284
  const dir = resolve2(dirArg ?? ".");
4470
4285
  const pkg = await readPackageJson(dir);
4471
4286
  const facts = { indexHtml: await exists(resolve2(dir, "index.html")), dockerfile: await exists(resolve2(dir, "Dockerfile")) };
@@ -4550,7 +4365,7 @@ function parsePort(v) {
4550
4365
  var exists = (path) => access4(path).then(() => true, () => false);
4551
4366
  async function readPackageJson(dir) {
4552
4367
  try {
4553
- return JSON.parse(await readFile8(resolve2(dir, "package.json"), "utf8"));
4368
+ return JSON.parse(await readFile7(resolve2(dir, "package.json"), "utf8"));
4554
4369
  } catch (err) {
4555
4370
  if (err.code === "ENOENT") return void 0;
4556
4371
  throw new KvboxError(`${resolve2(dir, "package.json")}: ${err.message}`);
@@ -4676,15 +4491,15 @@ the app is on box ${ref} but has no address yet: pick another with kvbox deploy
4676
4491
  }
4677
4492
 
4678
4493
  // src/commands/volume/index.ts
4679
- import { Command as Command67 } from "commander";
4494
+ import { Command as Command59 } from "commander";
4680
4495
 
4681
4496
  // src/commands/volume/attach.ts
4682
- import { Command as Command62 } from "commander";
4497
+ import { Command as Command54 } from "commander";
4683
4498
  function describeMount(machine, volume, box) {
4684
4499
  const path = machine.volumes?.find((v) => volume === v.name || volume.endsWith(`/${v.name}`))?.mountPath ?? volumeMountPath(volume.slice(volume.lastIndexOf("/") + 1));
4685
4500
  return machine.status === "running" ? ` the box was restarted; the volume is at ${path} inside it` : ` box ${box} is ${machine.status}; the volume is at ${path} once it runs`;
4686
4501
  }
4687
- var attachCommand = new Command62("attach").description("attach a volume to a box at /mnt/<volume> (a running box is restarted to take it)").argument("[volume]", "volume name (picked from a list when left out)").argument("[box]", "box name (picked from a list when left out)").option("--json", "print the box as JSON").action(async (volumeArg, boxArg, opts, cmd) => {
4502
+ var attachCommand = new Command54("attach").description("attach a volume to a box at /mnt/<volume> (a running box is restarted to take it)").argument("[volume]", "volume name (picked from a list when left out)").argument("[box]", "box name (picked from a list when left out)").option("--json", "print the box as JSON").action(async (volumeArg, boxArg, opts, cmd) => {
4688
4503
  if (volumeArg === void 0 || boxArg === void 0) askOrUsage("give the volume and the box: kvbox volume attach <volume> <box>");
4689
4504
  const client = await clientFor(cmd.optsWithGlobals());
4690
4505
  try {
@@ -4703,7 +4518,7 @@ var attachCommand = new Command62("attach").description("attach a volume to a bo
4703
4518
  });
4704
4519
 
4705
4520
  // src/commands/volume/create.ts
4706
- import { Command as Command63 } from "commander";
4521
+ import { Command as Command55 } from "commander";
4707
4522
  function parseGib2(text2) {
4708
4523
  const mib = parseMib(text2);
4709
4524
  if (mib === void 0 || mib % 1024 !== 0) throw new KvboxError(`--size ${text2}: write whole GB, like 50 or 50GB`);
@@ -4719,7 +4534,7 @@ function sizeProblem(answer) {
4719
4534
  return err instanceof KvboxError ? err.message.replace(/^--size \S+: /, "") : String(err);
4720
4535
  }
4721
4536
  }
4722
- var createCommand3 = new Command63("create").alias("new").description("create a volume for a box: an empty disk of its own at /mnt/<name> inside it (a running box is restarted)").argument("[name]", "volume name (1-12 chars; the box mounts it at /mnt/<name>; asked for when left out)").option("--size <gb>", "size in GB, like 50 or 50GB (whole GB; it only occupies what is written)").option("--box <box>", "the box it is for: made on that box's host and attached to it (required on kvbox.sh; optional with --local)").option("--json", "print the volume as JSON").action(async (nameArg, opts, cmd) => {
4537
+ var createCommand3 = new Command55("create").alias("new").description("create a volume for a box: an empty disk of its own at /mnt/<name> inside it (a running box is restarted)").argument("[name]", "volume name (1-12 chars; the box mounts it at /mnt/<name>; asked for when left out)").option("--size <gb>", "size in GB, like 50 or 50GB (whole GB; it only occupies what is written)").option("--box <box>", "the box it is for: made on that box's host and attached to it (required on kvbox.sh; optional with --local)").option("--json", "print the volume as JSON").action(async (nameArg, opts, cmd) => {
4723
4538
  const ask = interactive();
4724
4539
  if (nameArg === void 0 || opts.size === void 0) askOrUsage("give the name and the size: kvbox volume create <name> --size <gb> --box <box>");
4725
4540
  const name = nameArg ?? await text("Volume name", { validate: (a) => VOLUME_NAME_RE.test(a) ? void 0 : VOLUME_NAME_RULE });
@@ -4752,8 +4567,8 @@ var createCommand3 = new Command63("create").alias("new").description("create a
4752
4567
  });
4753
4568
 
4754
4569
  // src/commands/volume/detach.ts
4755
- import { Command as Command64 } from "commander";
4756
- var detachCommand = new Command64("detach").description("detach a volume from a box; its data is kept (a running box is restarted)").argument("[volume]", "volume name (picked from a list when left out)").argument("[box]", "box name (the one the volume is on when left out)").option("--json", "print the box as JSON").action(async (volumeArg, boxArg, opts, cmd) => {
4570
+ import { Command as Command56 } from "commander";
4571
+ var detachCommand = new Command56("detach").description("detach a volume from a box; its data is kept (a running box is restarted)").argument("[volume]", "volume name (picked from a list when left out)").argument("[box]", "box name (the one the volume is on when left out)").option("--json", "print the box as JSON").action(async (volumeArg, boxArg, opts, cmd) => {
4757
4572
  if (volumeArg === void 0) askOrUsage("give the volume: kvbox volume detach <volume> [box]");
4758
4573
  const client = await clientFor(cmd.optsWithGlobals());
4759
4574
  try {
@@ -4778,8 +4593,8 @@ var detachCommand = new Command64("detach").description("detach a volume from a
4778
4593
  });
4779
4594
 
4780
4595
  // src/commands/volume/ls.ts
4781
- import { Command as Command65 } from "commander";
4782
- var lsCommand8 = new Command65("ls").alias("list").description("list volumes: size, what they occupy, which box has them").option("-a, --all", "every volume on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
4596
+ import { Command as Command57 } from "commander";
4597
+ var lsCommand8 = new Command57("ls").alias("list").description("list volumes: size, what they occupy, which box has them").option("-a, --all", "every volume on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
4783
4598
  const client = await clientFor(cmd.optsWithGlobals());
4784
4599
  try {
4785
4600
  const cloud = client.target.kind === "cloud";
@@ -4810,8 +4625,8 @@ var lsCommand8 = new Command65("ls").alias("list").description("list volumes: si
4810
4625
  });
4811
4626
 
4812
4627
  // src/commands/volume/rm.ts
4813
- import { Command as Command66 } from "commander";
4814
- var rmCommand7 = new Command66("rm").alias("remove").description("delete a volume and everything on it (detach it first)").argument("<name>", "volume name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
4628
+ import { Command as Command58 } from "commander";
4629
+ var rmCommand7 = new Command58("rm").alias("remove").description("delete a volume and everything on it (detach it first)").argument("<name>", "volume name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
4815
4630
  if (!await confirm(`Delete volume ${name} and everything on it?`, opts.yes ?? false)) {
4816
4631
  info("cancelled");
4817
4632
  process.exitCode = 1;
@@ -4827,14 +4642,14 @@ var rmCommand7 = new Command66("rm").alias("remove").description("delete a volum
4827
4642
  });
4828
4643
 
4829
4644
  // src/commands/volume/index.ts
4830
- var volumeCommand = new Command67("volume").aliases(["volumes", "vol"]).description("disks of their own: create one, attach it to a box at /mnt/<name>, move it to another box later").addCommand(createCommand3).addCommand(lsCommand8).addCommand(attachCommand).addCommand(detachCommand).addCommand(rmCommand7);
4645
+ var volumeCommand = new Command59("volume").aliases(["volumes", "vol"]).description("disks of their own: create one, attach it to a box at /mnt/<name>, move it to another box later").addCommand(createCommand3).addCommand(lsCommand8).addCommand(attachCommand).addCommand(detachCommand).addCommand(rmCommand7);
4831
4646
  for (const cmd of volumeCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
4832
4647
 
4833
4648
  // src/commands/env/index.ts
4834
- import { Command as Command71 } from "commander";
4649
+ import { Command as Command63 } from "commander";
4835
4650
 
4836
4651
  // src/commands/env/ls.ts
4837
- import { Command as Command68 } from "commander";
4652
+ import { Command as Command60 } from "commander";
4838
4653
 
4839
4654
  // src/commands/env/shared.ts
4840
4655
  function requireCloud4(client) {
@@ -4861,7 +4676,7 @@ function firstBootHint(box, name) {
4861
4676
  }
4862
4677
 
4863
4678
  // src/commands/env/ls.ts
4864
- var lsCommand9 = new Command68("ls").alias("list").description("list the variables (a secret shows as (sealed))").option("--box <box>", "what this box gets: its own variables and the ones it inherits").option("--json", "print as JSON").action(async (opts, cmd) => {
4679
+ var lsCommand9 = new Command60("ls").alias("list").description("list the variables (a secret shows as (sealed))").option("--box <box>", "what this box gets: its own variables and the ones it inherits").option("--json", "print as JSON").action(async (opts, cmd) => {
4865
4680
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
4866
4681
  try {
4867
4682
  if (opts.box !== void 0) {
@@ -4900,8 +4715,8 @@ var lsCommand9 = new Command68("ls").alias("list").description("list the variabl
4900
4715
  });
4901
4716
 
4902
4717
  // src/commands/env/rm.ts
4903
- import { Command as Command69 } from "commander";
4904
- var rmCommand8 = new Command69("rm").alias("remove").description("remove variables; boxes lose them when they next start").argument("<names...>", "variable names").option("-y, --yes", "do not ask for confirmation").option("--box <box>", "remove this box's own variables (yours, or the org's, of the same name come back)").option("--json", "print as JSON").action(async (names2, opts, cmd) => {
4718
+ import { Command as Command61 } from "commander";
4719
+ var rmCommand8 = new Command61("rm").alias("remove").description("remove variables; boxes lose them when they next start").argument("<names...>", "variable names").option("-y, --yes", "do not ask for confirmation").option("--box <box>", "remove this box's own variables (yours, or the org's, of the same name come back)").option("--json", "print as JSON").action(async (names2, opts, cmd) => {
4905
4720
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
4906
4721
  try {
4907
4722
  const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
@@ -4938,8 +4753,8 @@ var rmCommand8 = new Command69("rm").alias("remove").description("remove variabl
4938
4753
  });
4939
4754
 
4940
4755
  // src/commands/env/set.ts
4941
- import { Command as Command70 } from "commander";
4942
- var setCommand2 = new Command70("set").description("add or change a variable; boxes get it when they next start").argument("[name]", "variable name, e.g. DATABASE_URL (asked for when left out)").argument("[value]", "its value (asked for when left out; hidden with --secret)").option("--secret", "write-only: the value is never shown again, by any command").option("--box <box>", "this box's own variable, over yours (or the org's) of the same name").option("--json", "print as JSON").action(async (nameArg, valueArg, opts, cmd) => {
4756
+ import { Command as Command62 } from "commander";
4757
+ var setCommand2 = new Command62("set").description("add or change a variable; boxes get it when they next start").argument("[name]", "variable name, e.g. DATABASE_URL (asked for when left out)").argument("[value]", "its value (asked for when left out; hidden with --secret)").option("--secret", "write-only: the value is never shown again, by any command").option("--box <box>", "this box's own variable, over yours (or the org's) of the same name").option("--json", "print as JSON").action(async (nameArg, valueArg, opts, cmd) => {
4943
4758
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
4944
4759
  try {
4945
4760
  const owner = opts.box === void 0 ? requireCloud4(client) : void 0;
@@ -4976,14 +4791,14 @@ var setCommand2 = new Command70("set").description("add or change a variable; bo
4976
4791
  });
4977
4792
 
4978
4793
  // src/commands/env/index.ts
4979
- var envCommand = new Command71("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand9, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand8);
4794
+ var envCommand = new Command63("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand9, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand8);
4980
4795
  for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
4981
4796
 
4982
4797
  // src/commands/domain/index.ts
4983
- import { Command as Command75 } from "commander";
4798
+ import { Command as Command67 } from "commander";
4984
4799
 
4985
4800
  // src/commands/domain/add.ts
4986
- import { Command as Command72 } from "commander";
4801
+ import { Command as Command64 } from "commander";
4987
4802
 
4988
4803
  // src/commands/domain/shared.ts
4989
4804
  function requireCloud5(client) {
@@ -5003,7 +4818,7 @@ function hostIn(name, zone) {
5003
4818
  }
5004
4819
 
5005
4820
  // src/commands/domain/add.ts
5006
- var addCommand3 = new Command72("add").description("serve a box at a domain of your own, https://<domain>, with its certificate made for you").argument("<domain>", "a domain you control, like example.com or app.example.com").argument("<box>", "box name").option("--port <port>", "the box port the domain serves (default: the port of its kvbox.app address)").option("--json", "print the domain as JSON").action(async (domainArg, name, opts, cmd) => {
4821
+ var addCommand3 = new Command64("add").description("serve a box at a domain of your own, https://<domain>, with its certificate made for you").argument("<domain>", "a domain you control, like example.com or app.example.com").argument("<box>", "box name").option("--port <port>", "the box port the domain serves (default: the port of its kvbox.app address)").option("--json", "print the domain as JSON").action(async (domainArg, name, opts, cmd) => {
5007
4822
  const domain = assertDomain(domainArg.trim().toLowerCase());
5008
4823
  const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
5009
4824
  const client = await clientFor(cmd.optsWithGlobals());
@@ -5039,8 +4854,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
5039
4854
  });
5040
4855
 
5041
4856
  // src/commands/domain/ls.ts
5042
- import { Command as Command73 } from "commander";
5043
- var lsCommand10 = new Command73("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
4857
+ import { Command as Command65 } from "commander";
4858
+ var lsCommand10 = new Command65("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
5044
4859
  const client = await clientFor(cmd.optsWithGlobals());
5045
4860
  try {
5046
4861
  requireCloud5(client);
@@ -5069,8 +4884,8 @@ var lsCommand10 = new Command73("ls").alias("list").description("list your custo
5069
4884
  });
5070
4885
 
5071
4886
  // src/commands/domain/rm.ts
5072
- import { Command as Command74 } from "commander";
5073
- var rmCommand9 = new Command74("rm").alias("remove").description("stop serving a box at a custom domain").argument("<domain>", "the domain").option("-y, --yes", "do not ask for confirmation").action(async (domainArg, opts, cmd) => {
4887
+ import { Command as Command66 } from "commander";
4888
+ var rmCommand9 = new Command66("rm").alias("remove").description("stop serving a box at a custom domain").argument("<domain>", "the domain").option("-y, --yes", "do not ask for confirmation").action(async (domainArg, opts, cmd) => {
5074
4889
  const domain = domainArg.trim().toLowerCase();
5075
4890
  const client = await clientFor(cmd.optsWithGlobals());
5076
4891
  try {
@@ -5091,15 +4906,15 @@ var rmCommand9 = new Command74("rm").alias("remove").description("stop serving a
5091
4906
  });
5092
4907
 
5093
4908
  // src/commands/domain/index.ts
5094
- var domainCommand = new Command75("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand3).addCommand(lsCommand10).addCommand(rmCommand9);
4909
+ var domainCommand = new Command67("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand3).addCommand(lsCommand10).addCommand(rmCommand9);
5095
4910
  for (const cmd of domainCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
5096
4911
 
5097
4912
  // src/commands/update.ts
5098
- import { spawn as spawn7 } from "child_process";
4913
+ import { spawn as spawn6 } from "child_process";
5099
4914
  import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
5100
4915
  import { tmpdir } from "os";
5101
4916
  import { join as join8 } from "path";
5102
- import { Command as Command76 } from "commander";
4917
+ import { Command as Command68 } from "commander";
5103
4918
 
5104
4919
  // src/update.ts
5105
4920
  import { mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
@@ -5213,12 +5028,12 @@ async function download(url) {
5213
5028
  }
5214
5029
  function run(cmd, args) {
5215
5030
  return new Promise((resolve3, reject) => {
5216
- const child = spawn7(cmd, args, { stdio: "inherit" });
5031
+ const child = spawn6(cmd, args, { stdio: "inherit" });
5217
5032
  child.on("error", (err) => reject(new KvboxError(`could not run ${cmd}: ${err.message}`)));
5218
5033
  child.on("exit", (code, signal) => resolve3(code ?? (signal ? 1 : 0)));
5219
5034
  });
5220
5035
  }
5221
- var selfUpdateCommand = new Command76("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
5036
+ var selfUpdateCommand = new Command68("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
5222
5037
  suppressUpdateNotice();
5223
5038
  const inst = installerFor(process.platform, process.env["KVBOX_INSTALL_URL"] || INSTALL_BASE);
5224
5039
  let code;
@@ -5240,13 +5055,12 @@ var selfUpdateCommand = new Command76("update").description("update kvbox to the
5240
5055
 
5241
5056
  // src/program.ts
5242
5057
  function buildProgram() {
5243
- const program = new Command77("kvbox").description("self-hosted Firecracker microVMs with Docker-like ergonomics").version(VERSION, "-v, --version").option("--local", "use this machine's kvbox-server over its socket, ignoring kvbox login").option("--org <slug>", "the org: where kvbox new creates, and which box a name means when it is not one of yours; before the command here, or after it").showHelpAfterError().enablePositionalOptions();
5058
+ const program = new Command69("kvbox").description("self-hosted Firecracker microVMs with Docker-like ergonomics").version(VERSION, "-v, --version").option("--local", "use this machine's kvbox-server over its socket, ignoring kvbox login").option("--org <slug>", "the org: where kvbox new creates, and which box a name means when it is not one of yours; before the command here, or after it").showHelpAfterError().enablePositionalOptions();
5244
5059
  program.addCommand(vmCommand);
5245
5060
  program.addCommand(snapshotsCommand);
5246
5061
  program.addCommand(volumeCommand);
5247
5062
  program.addCommand(envCommand);
5248
5063
  program.addCommand(domainCommand);
5249
- program.addCommand(serverCommand);
5250
5064
  program.addCommand(loginCommand);
5251
5065
  program.addCommand(logoutCommand);
5252
5066
  program.addCommand(whoamiCommand);