@kvbox/cli 0.5.27 → 0.5.28

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 Command65 } from "commander";
152
+ import { Command as Command68 } from "commander";
153
153
 
154
154
  // ../shared/src/version.ts
155
155
  import { createRequire } from "module";
@@ -164,10 +164,10 @@ function versionOf(srcFileUrl, injected) {
164
164
  }
165
165
 
166
166
  // src/version.ts
167
- var VERSION = versionOf(import.meta.url, true ? "0.5.27" : void 0);
167
+ var VERSION = versionOf(import.meta.url, true ? "0.5.28" : void 0);
168
168
 
169
169
  // src/commands/vm/index.ts
170
- import { Command as Command26 } from "commander";
170
+ import { Command as Command29 } from "commander";
171
171
 
172
172
  // src/commands/vm/connect.ts
173
173
  import { spawnSync as spawnSync2 } from "child_process";
@@ -431,6 +431,8 @@ var PortsRequest = z2.object({
431
431
  ports: z2.array(z2.object({ guestPort: z2.number().int().min(1).max(65535), proto: PortProtoSchema.optional() })).min(1).max(MAX_BOX_PORTS)
432
432
  });
433
433
  var BoxPortSchema = z2.number().int().min(1).max(65535);
434
+ var BoxLinkSchema = z2.object({ from: z2.string(), port: BoxPortSchema });
435
+ var LinkRequest = z2.object({ from: z2.string().min(1), fromOwner: z2.string().optional(), port: BoxPortSchema });
434
436
  var ClaimSubdomainRequest = z2.object({ name: z2.string(), port: BoxPortSchema });
435
437
  var SubdomainPortRequest = z2.object({ port: BoxPortSchema });
436
438
  var SubdomainRouteRequest = z2.object({ name: z2.string(), port: BoxPortSchema });
@@ -494,7 +496,9 @@ var MachineSchema = z2.object({
494
496
  /** Seconds without network traffic before the host hibernates the box (#47). Absent: never. */
495
497
  autoHibernateSec: z2.number().int().positive().optional(),
496
498
  /** Volumes attached to the box (#52), in drive order; each is mounted at `mountPath` while the box runs. Absent: none. */
497
- volumes: z2.array(z2.object({ name: z2.string(), sizeGib: z2.number().int(), mountPath: z2.string() })).optional()
499
+ volumes: z2.array(z2.object({ name: z2.string(), sizeGib: z2.number().int(), mountPath: z2.string() })).optional(),
500
+ /** Boxes that may reach this one, each on one port (#98). Absent: none. */
501
+ links: z2.array(BoxLinkSchema).optional()
498
502
  });
499
503
  var VolumeSchema = z2.object({
500
504
  /** The host's 6-hex volume id (#91): the ledger's key, so a name removed and made again is two volumes. */
@@ -559,7 +563,12 @@ var CreateMachineRequest = z2.object({
559
563
  */
560
564
  sshKeys: z2.array(z2.string()).optional(),
561
565
  /** Seconds without network traffic before the box is hibernated (#47); 0: never. Absent: the host's default. */
562
- autoHibernateSec: z2.number().int().min(0).optional()
566
+ autoHibernateSec: z2.number().int().min(0).optional(),
567
+ /**
568
+ * Place the box on the host of this box (#98, `kvbox new --near`), so the two can be linked. Only the
569
+ * control plane reads it; a host has one place to put a box.
570
+ */
571
+ near: z2.string().optional()
563
572
  });
564
573
  var ForkMachineRequest = z2.object({
565
574
  name: z2.string().optional(),
@@ -603,7 +612,9 @@ var SnapshotSchema = z2.object({
603
612
  });
604
613
  var CreateSnapshotRequest = z2.object({
605
614
  box: z2.string(),
606
- name: z2.string()
615
+ name: z2.string(),
616
+ /** Retake a snapshot under a name that exists (#83): the old one goes only once the new one is complete. */
617
+ replace: z2.boolean().optional()
607
618
  });
608
619
  var DiskCapacitySchema = z2.object({
609
620
  totalGib: z2.number().int(),
@@ -1137,6 +1148,14 @@ var ServerClient = class {
1137
1148
  removePorts(name, req) {
1138
1149
  return this.call("DELETE", `/machines/${encodeURIComponent(name)}/ports`, MachineSchema, req);
1139
1150
  }
1151
+ /** Let box `from` reach this box's `port` (#98); the answer is the box with every link into it. */
1152
+ addLink(name, req) {
1153
+ return this.call("POST", `/machines/${encodeURIComponent(name)}/links`, MachineSchema, req);
1154
+ }
1155
+ /** Take a link away (#98). */
1156
+ removeLink(name, req) {
1157
+ return this.call("DELETE", `/machines/${encodeURIComponent(name)}/links`, MachineSchema, req);
1158
+ }
1140
1159
  /** HTTPS names (#31), the control plane's only: the box's subdomain, claimed for its default port. */
1141
1160
  claimSubdomain(name, req) {
1142
1161
  return this.call("PUT", `/machines/${encodeURIComponent(name)}/subdomain`, SubdomainSchema, req);
@@ -1625,7 +1644,7 @@ async function pickVolume(client, keep, none) {
1625
1644
 
1626
1645
  // src/commands/vm/new.ts
1627
1646
  import { Command, Option } from "commander";
1628
- var newCommand = new Command("new").description("boot a new box from the base image or a snapshot").argument("[name]", "box name (box1, box2, \u2026 when omitted)").addOption(new Option("-s, --size <size>", "box size (default: server config, s)").choices(SIZE_NAMES)).option("-f, --from <snapshot>", "start from a snapshot instead of the base image").option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never; default: server config, off)").option("--force", "skip the capacity guard").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
1647
+ var newCommand = new Command("new").description("boot a new box from the base image or a snapshot").argument("[name]", "box name (box1, box2, \u2026 when omitted)").addOption(new Option("-s, --size <size>", "box size (default: server config, s)").choices(SIZE_NAMES)).option("-f, --from <snapshot>", "start from a snapshot instead of the base image").option("--near <box>", "put it on the same host as this box, so the two can be linked (kvbox vm link)").option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never; default: server config, off)").option("--force", "skip the capacity guard").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
1629
1648
  const autoHibernateSec = opts.autoHibernate === void 0 ? void 0 : parseIdleTimeout(opts.autoHibernate);
1630
1649
  const client = await clientFor(cmd.optsWithGlobals());
1631
1650
  try {
@@ -1634,6 +1653,7 @@ var newCommand = new Command("new").description("boot a new box from the base im
1634
1653
  ...name !== void 0 ? { name } : {},
1635
1654
  ...opts.size !== void 0 ? { size: opts.size } : {},
1636
1655
  ...opts.from !== void 0 ? { from: opts.from } : {},
1656
+ ...opts.near !== void 0 ? { near: opts.near } : {},
1637
1657
  ...autoHibernateSec !== void 0 ? { autoHibernateSec } : {},
1638
1658
  ...opts.force ? { force: true } : {}
1639
1659
  }));
@@ -1975,9 +1995,72 @@ var hibernateCommand = new Command7("hibernate").description("save a box's memor
1975
1995
  }
1976
1996
  });
1977
1997
 
1978
- // src/commands/vm/pause.ts
1998
+ // src/commands/vm/link.ts
1979
1999
  import { Command as Command8 } from "commander";
1980
- var pauseCommand = new Command8("pause").description("freeze a box in place (memory and processes kept, no CPU used; kvbox resume continues it instantly)").argument("<name>", "box name").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
2000
+ function parseLinkPort(text2) {
2001
+ const port = Number(text2);
2002
+ if (!Number.isInteger(port) || port < 1 || port > 65535) throw new KvboxError(`--port: expected a port from 1 to 65535, got "${text2}"`);
2003
+ return port;
2004
+ }
2005
+ var linkCommand = new Command8("link").description("let one box reach a port of another (private, same host; never public)").argument("<from>", "the box that connects").argument("<box>", "the box it may reach").requiredOption("-p, --port <port>", "the port in <box>").option("--json", "print the link as JSON").action(async (from, name, opts, cmd) => {
2006
+ const port = parseLinkPort(opts.port);
2007
+ const client = await clientFor(cmd.optsWithGlobals());
2008
+ try {
2009
+ const box = await spin(`linking ${from} to ${name}:${port}\u2026`, client.addLink(name, { from, port }));
2010
+ const user = me(client);
2011
+ const shown = displayName(box, user);
2012
+ if (opts.json) {
2013
+ json({ from, box: shown, port });
2014
+ return;
2015
+ }
2016
+ const fromName = from.slice(from.lastIndexOf("/") + 1);
2017
+ const link = box.links?.find((l) => l.port === port && l.from.slice(l.from.lastIndexOf("/") + 1) === fromName);
2018
+ const apart = link !== void 0 ? link.from.includes("/") : from.includes("/") && from.split("/")[0] !== slugOf(box.owner);
2019
+ const host = apart ? `${box.name}.${slugOf(box.owner)}.kvbox` : `${box.name}.kvbox`;
2020
+ info(`${color.green("\u2713")} box ${color.bold(from)} can reach ${color.bold(`${host}:${port}`)}`);
2021
+ if (box.status !== "running") info(` box ${shown} is ${box.status}: the link opens when it runs`);
2022
+ } finally {
2023
+ await client.close();
2024
+ }
2025
+ });
2026
+
2027
+ // src/commands/vm/links.ts
2028
+ import { Command as Command9 } from "commander";
2029
+ var linksCommand = new Command9("links").description("list the links between boxes (kvbox vm link)").argument("[box]", "only links into or out of this box").option("--json", "print as JSON").action(async (name, opts, cmd) => {
2030
+ const client = await clientFor(cmd.optsWithGlobals());
2031
+ try {
2032
+ const user = me(client);
2033
+ const machines = await client.listMachines();
2034
+ const picked = name === void 0 ? void 0 : pickRef(machines, name, user);
2035
+ const unlisted = name === void 0 || name.includes("/") || user === void 0 ? name : `${client.target.kind === "cloud" ? client.target.org ?? user : user}/${name}`;
2036
+ const wanted = picked === void 0 ? unlisted : `${slugOf(picked.owner)}/${picked.name}`;
2037
+ const rows2 = machines.flatMap((b) => {
2038
+ const box = displayName(b, user);
2039
+ const slug = box.includes("/") ? box.split("/")[0] : void 0;
2040
+ return (b.links ?? []).map((l) => {
2041
+ const source = l.from.includes("/") ? l.from : `${slugOf(b.owner)}/${l.from}`;
2042
+ const from = slug !== void 0 && !l.from.includes("/") ? `${slug}/${l.from}` : l.from;
2043
+ const row = { from: user !== void 0 && from.startsWith(`${user}/`) ? from.slice(user.length + 1) : from, box, port: l.port };
2044
+ return { row, ends: [`${slugOf(b.owner)}/${b.name}`, source] };
2045
+ });
2046
+ }).filter((r) => wanted === void 0 || r.ends.includes(wanted)).map((r) => r.row).sort((a, b) => a.box.localeCompare(b.box) || a.from.localeCompare(b.from) || a.port - b.port);
2047
+ if (opts.json) {
2048
+ json(rows2);
2049
+ return;
2050
+ }
2051
+ if (rows2.length === 0) {
2052
+ info(name === void 0 ? "no links (kvbox vm link <from> <box> --port <port>)" : `box ${name} has no links`);
2053
+ return;
2054
+ }
2055
+ table(rows2);
2056
+ } finally {
2057
+ await client.close();
2058
+ }
2059
+ });
2060
+
2061
+ // src/commands/vm/pause.ts
2062
+ import { Command as Command10 } from "commander";
2063
+ var pauseCommand = new Command10("pause").description("freeze a box in place (memory and processes kept, no CPU used; kvbox resume continues it instantly)").argument("<name>", "box name").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
1981
2064
  const client = await clientFor(cmd.optsWithGlobals());
1982
2065
  try {
1983
2066
  const box = await spin(`pausing ${name}\u2026`, client.pauseMachine(name));
@@ -1989,7 +2072,7 @@ var pauseCommand = new Command8("pause").description("freeze a box in place (mem
1989
2072
  });
1990
2073
 
1991
2074
  // src/commands/vm/proxy/claim.ts
1992
- import { Command as Command9 } from "commander";
2075
+ import { Command as Command11 } from "commander";
1993
2076
 
1994
2077
  // ../shared/src/names.ts
1995
2078
  import { createHmac } from "crypto";
@@ -2059,7 +2142,7 @@ function assertDomain(text2, proxyDomain) {
2059
2142
  }
2060
2143
 
2061
2144
  // src/commands/vm/proxy/claim.ts
2062
- var claimCommand = new Command9("claim").description("give a box its HTTPS address, https://<subdomain>.kvbox.app, serving one of its ports").argument("[box]", "box name (picked from a list when left out)").argument("[subdomain]", "3-63 lowercase letters, digits and '-'; must be free (asked for when left out)").option("--port <port>", "the box port the address serves (asked for when left out)").option("--json", "print the subdomain as JSON").action(async (nameArg, subArg, opts, cmd) => {
2145
+ var claimCommand = new Command11("claim").description("give a box its HTTPS address, https://<subdomain>.kvbox.app, serving one of its ports").argument("[box]", "box name (picked from a list when left out)").argument("[subdomain]", "3-63 lowercase letters, digits and '-'; must be free (asked for when left out)").option("--port <port>", "the box port the address serves (asked for when left out)").option("--json", "print the subdomain as JSON").action(async (nameArg, subArg, opts, cmd) => {
2063
2146
  if (nameArg === void 0 || subArg === void 0 || opts.port === void 0) askOrUsage("give the box, the subdomain and the port: kvbox vm proxy claim <box> <subdomain> --port <port>");
2064
2147
  if (subArg !== void 0) assertSubdomain(subArg);
2065
2148
  if (opts.port !== void 0) parsePorts([opts.port]);
@@ -2087,11 +2170,11 @@ var claimCommand = new Command9("claim").description("give a box its HTTPS addre
2087
2170
  });
2088
2171
 
2089
2172
  // src/commands/vm/proxy/index.ts
2090
- import { Command as Command15 } from "commander";
2173
+ import { Command as Command17 } from "commander";
2091
2174
 
2092
2175
  // src/commands/vm/proxy/add.ts
2093
- import { Command as Command10 } from "commander";
2094
- var addCommand = new Command10("add").description("publish box ports on the internet; each gets a random public port, or an HTTPS name with --name").argument("<box>", "box name").argument("<port...>", "ports inside the box, e.g. 3000 8080").option("--udp", "UDP instead of TCP").option("--name <name>", "serve the port at https://<name>.<subdomain>.kvbox.app (one port; needs kvbox vm proxy claim first)").option("--json", "print the new forwards as JSON").action(async (name, portTexts, opts, cmd) => {
2176
+ import { Command as Command12 } from "commander";
2177
+ var addCommand = new Command12("add").description("publish box ports on the internet; each gets a random public port, or an HTTPS name with --name").argument("<box>", "box name").argument("<port...>", "ports inside the box, e.g. 3000 8080").option("--udp", "UDP instead of TCP").option("--name <name>", "serve the port at https://<name>.<subdomain>.kvbox.app (one port; needs kvbox vm proxy claim first)").option("--json", "print the new forwards as JSON").action(async (name, portTexts, opts, cmd) => {
2095
2178
  const guestPorts = parsePorts(portTexts);
2096
2179
  if (opts.name !== void 0) {
2097
2180
  assertRouteName(opts.name);
@@ -2132,7 +2215,7 @@ var addCommand = new Command10("add").description("publish box ports on the inte
2132
2215
  });
2133
2216
 
2134
2217
  // src/commands/vm/proxy/ls.ts
2135
- import { Command as Command11 } from "commander";
2218
+ import { Command as Command13 } from "commander";
2136
2219
  async function subdomainsOf(client) {
2137
2220
  try {
2138
2221
  return await client.listSubdomains();
@@ -2141,7 +2224,7 @@ async function subdomainsOf(client) {
2141
2224
  return [];
2142
2225
  }
2143
2226
  }
2144
- var lsCommand2 = new Command11("ls").description("list the box ports published on the internet").argument("[box]", "only this box").option("--json", "print as JSON").action(async (name, opts, cmd) => {
2227
+ var lsCommand2 = new Command13("ls").description("list the box ports published on the internet").argument("[box]", "only this box").option("--json", "print as JSON").action(async (name, opts, cmd) => {
2145
2228
  const client = await clientFor(cmd.optsWithGlobals());
2146
2229
  try {
2147
2230
  const user = me(client);
@@ -2167,8 +2250,8 @@ var lsCommand2 = new Command11("ls").description("list the box ports published o
2167
2250
  });
2168
2251
 
2169
2252
  // src/commands/vm/proxy/release.ts
2170
- import { Command as Command12 } from "commander";
2171
- var releaseCommand = new Command12("release").description("give up a box's HTTPS address and every name under it").argument("<box>", "box name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
2253
+ import { Command as Command14 } from "commander";
2254
+ var releaseCommand = new Command14("release").description("give up a box's HTTPS address and every name under it").argument("<box>", "box name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
2172
2255
  const client = await clientFor(cmd.optsWithGlobals());
2173
2256
  try {
2174
2257
  requireCloud(client);
@@ -2187,8 +2270,8 @@ var releaseCommand = new Command12("release").description("give up a box's HTTPS
2187
2270
  });
2188
2271
 
2189
2272
  // src/commands/vm/proxy/rm.ts
2190
- import { Command as Command13 } from "commander";
2191
- var rmCommand = new Command13("rm").description("stop publishing box ports, or an HTTPS name with --name").argument("<box>", "box name").argument("[port...]", "ports inside the box, as given to add").option("--udp", "the UDP forwards of those ports").option("--name <name>", "the HTTPS name to free (kvbox vm proxy release frees the whole subdomain)").option("-y, --yes", "do not ask for confirmation").action(async (name, portTexts, opts, cmd) => {
2273
+ import { Command as Command15 } from "commander";
2274
+ var rmCommand = new Command15("rm").description("stop publishing box ports, or an HTTPS name with --name").argument("<box>", "box name").argument("[port...]", "ports inside the box, as given to add").option("--udp", "the UDP forwards of those ports").option("--name <name>", "the HTTPS name to free (kvbox vm proxy release frees the whole subdomain)").option("-y, --yes", "do not ask for confirmation").action(async (name, portTexts, opts, cmd) => {
2192
2275
  if (opts.name !== void 0) {
2193
2276
  assertRouteName(opts.name);
2194
2277
  if (portTexts.length > 0) throw new KvboxError("--name frees a name, not ports: kvbox vm proxy rm <box> --name <name>");
@@ -2220,8 +2303,8 @@ var rmCommand = new Command13("rm").description("stop publishing box ports, or a
2220
2303
  });
2221
2304
 
2222
2305
  // src/commands/vm/proxy/set-port.ts
2223
- import { Command as Command14 } from "commander";
2224
- var setPortCommand = new Command14("set-port").description("point a box's HTTPS address at another of its ports").argument("<box>", "box name").argument("<port>", "the box port https://<subdomain>.kvbox.app serves from now on").option("--json", "print the subdomain as JSON").action(async (name, portText, opts, cmd) => {
2306
+ import { Command as Command16 } from "commander";
2307
+ var setPortCommand = new Command16("set-port").description("point a box's HTTPS address at another of its ports").argument("<box>", "box name").argument("<port>", "the box port https://<subdomain>.kvbox.app serves from now on").option("--json", "print the subdomain as JSON").action(async (name, portText, opts, cmd) => {
2225
2308
  const [port] = parsePorts([portText]);
2226
2309
  const client = await clientFor(cmd.optsWithGlobals());
2227
2310
  try {
@@ -2239,12 +2322,12 @@ var setPortCommand = new Command14("set-port").description("point a box's HTTPS
2239
2322
  });
2240
2323
 
2241
2324
  // src/commands/vm/proxy/index.ts
2242
- var proxyCommand = new Command15("proxy").description("publish box ports on the internet").addCommand(addCommand).addCommand(lsCommand2).addCommand(rmCommand).addCommand(claimCommand).addCommand(setPortCommand).addCommand(releaseCommand);
2325
+ var proxyCommand = new Command17("proxy").description("publish box ports on the internet").addCommand(addCommand).addCommand(lsCommand2).addCommand(rmCommand).addCommand(claimCommand).addCommand(setPortCommand).addCommand(releaseCommand);
2243
2326
  for (const cmd of proxyCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
2244
2327
 
2245
2328
  // src/commands/vm/rescale.ts
2246
- import { Command as Command16, Option as Option3 } from "commander";
2247
- var rescaleCommand = new Command16("rescale").description("change a box's vCPUs, memory or disk (e.g. --vcpu 4 --mem 16GB); a running box restarts").argument("<name>", "box name").addOption(new Option3("-s, --size <size>", "a preset to start from").choices(SIZE_NAMES)).option("--vcpu <n>", "number of vCPUs").option("--mem <size>", "memory, e.g. 16GB or 4096MB").option("--disk <size>", "disk size, e.g. 32GB (grow only)").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
2329
+ import { Command as Command18, Option as Option3 } from "commander";
2330
+ var rescaleCommand = new Command18("rescale").description("change a box's vCPUs, memory or disk (e.g. --vcpu 4 --mem 16GB); a running box restarts").argument("<name>", "box name").addOption(new Option3("-s, --size <size>", "a preset to start from").choices(SIZE_NAMES)).option("--vcpu <n>", "number of vCPUs").option("--mem <size>", "memory, e.g. 16GB or 4096MB").option("--disk <size>", "disk size, e.g. 32GB (grow only)").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
2248
2331
  const req = {
2249
2332
  ...opts.size !== void 0 ? { size: opts.size } : {},
2250
2333
  ...opts.vcpu !== void 0 ? { vcpu: parseCount(opts.vcpu) } : {},
@@ -2289,8 +2372,8 @@ function parseGib(flag, text2) {
2289
2372
  }
2290
2373
 
2291
2374
  // src/commands/vm/resume.ts
2292
- import { Command as Command17 } from "commander";
2293
- var resumeCommand = new Command17("resume").description("continue a box that is in standby (kvbox pause)").argument("<name>", "box name").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
2375
+ import { Command as Command19 } from "commander";
2376
+ var resumeCommand = new Command19("resume").description("continue a box that is in standby (kvbox pause)").argument("<name>", "box name").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
2294
2377
  const client = await clientFor(cmd.optsWithGlobals());
2295
2378
  try {
2296
2379
  const box = await spin(`resuming ${name}\u2026`, client.resumeMachine(name));
@@ -2302,8 +2385,8 @@ var resumeCommand = new Command17("resume").description("continue a box that is
2302
2385
  });
2303
2386
 
2304
2387
  // src/commands/vm/rm.ts
2305
- import { Command as Command18 } from "commander";
2306
- var rmCommand2 = new Command18("rm").description("destroy a box (its disk is deleted; snapshots are kept)").argument("<name>", "box name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
2388
+ import { Command as Command20 } from "commander";
2389
+ var rmCommand2 = new Command20("rm").description("destroy a box (its disk is deleted; snapshots are kept)").argument("<name>", "box name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
2307
2390
  const client = await clientFor(cmd.optsWithGlobals());
2308
2391
  try {
2309
2392
  const box = pickRef(await boxesFor(client, name), name, me(client));
@@ -2323,8 +2406,8 @@ var rmCommand2 = new Command18("rm").description("destroy a box (its disk is del
2323
2406
  });
2324
2407
 
2325
2408
  // src/commands/vm/set.ts
2326
- import { Command as Command19 } from "commander";
2327
- var setCommand = new Command19("set").description("change a box's settings, e.g. --auto-hibernate 30m (off: never)").argument("<name>", "box name").option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never)").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
2409
+ import { Command as Command21 } from "commander";
2410
+ var setCommand = new Command21("set").description("change a box's settings, e.g. --auto-hibernate 30m (off: never)").argument("<name>", "box name").option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never)").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
2328
2411
  if (opts.autoHibernate === void 0) throw new KvboxError("nothing to change: give --auto-hibernate");
2329
2412
  const autoHibernateSec = parseIdleTimeout(opts.autoHibernate);
2330
2413
  const client = await clientFor(cmd.optsWithGlobals());
@@ -2343,8 +2426,8 @@ var setCommand = new Command19("set").description("change a box's settings, e.g.
2343
2426
  });
2344
2427
 
2345
2428
  // src/commands/vm/start.ts
2346
- import { Command as Command20 } from "commander";
2347
- var startCommand = new Command20("start").description("boot a stopped box again (same name, IP and disk)").argument("<name>", "box name").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
2429
+ import { Command as Command22 } from "commander";
2430
+ var startCommand = new Command22("start").description("boot a stopped box again (same name, IP and disk)").argument("<name>", "box name").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
2348
2431
  const client = await clientFor(cmd.optsWithGlobals());
2349
2432
  try {
2350
2433
  const box = await spin(`booting ${name}\u2026`, client.startMachine(name));
@@ -2356,8 +2439,8 @@ var startCommand = new Command20("start").description("boot a stopped box again
2356
2439
  });
2357
2440
 
2358
2441
  // src/commands/vm/stop.ts
2359
- import { Command as Command21 } from "commander";
2360
- var stopCommand = new Command21("stop").description("shut a box down (its disk is kept; start it again with kvbox start)").argument("<name>", "box name").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
2442
+ import { Command as Command23 } from "commander";
2443
+ var stopCommand = new Command23("stop").description("shut a box down (its disk is kept; start it again with kvbox start)").argument("<name>", "box name").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
2361
2444
  const client = await clientFor(cmd.optsWithGlobals());
2362
2445
  try {
2363
2446
  const box = await spin(`shutting ${name} down\u2026`, client.stopMachine(name));
@@ -2369,8 +2452,8 @@ var stopCommand = new Command21("stop").description("shut a box down (its disk i
2369
2452
  });
2370
2453
 
2371
2454
  // src/commands/vm/top.ts
2372
- import { Command as Command22 } from "commander";
2373
- var topCommand = new Command22("top").description("load, memory and disk of each running box, as the box itself sees them").option("-a, --all", "every running box on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
2455
+ import { Command as Command24 } from "commander";
2456
+ var topCommand = new Command24("top").description("load, memory and disk of each running box, as the box itself sees them").option("-a, --all", "every running box on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
2374
2457
  const client = await clientFor(cmd.optsWithGlobals());
2375
2458
  try {
2376
2459
  const running = (await client.listMachines({ all: opts.all })).filter((b) => b.status === "running");
@@ -2429,9 +2512,31 @@ function topRows(entries, cloud) {
2429
2512
  });
2430
2513
  }
2431
2514
 
2515
+ // src/commands/vm/unlink.ts
2516
+ import { Command as Command25 } from "commander";
2517
+ var unlinkCommand = new Command25("unlink").description("take a link away (kvbox vm link)").argument("<from>", "the box that connects").argument("<box>", "the box it reaches").requiredOption("-p, --port <port>", "the port in <box>").option("-y, --yes", "do not ask for confirmation").option("--json", "print the removed link as JSON").action(async (from, name, opts, cmd) => {
2518
+ const port = parseLinkPort(opts.port);
2519
+ if (!await confirm(`Cut box ${from} off from box ${name} port ${port}? Its open connections close too.`, opts.yes ?? false)) {
2520
+ info("cancelled");
2521
+ process.exitCode = 1;
2522
+ return;
2523
+ }
2524
+ const client = await clientFor(cmd.optsWithGlobals());
2525
+ try {
2526
+ await spin(`unlinking ${from} from ${name}:${port}\u2026`, client.removeLink(name, { from, port }));
2527
+ if (opts.json) {
2528
+ json({ from, box: name, port });
2529
+ return;
2530
+ }
2531
+ info(`${color.green("\u2713")} box ${color.bold(from)} no longer reaches ${color.bold(name)} port ${port}`);
2532
+ } finally {
2533
+ await client.close();
2534
+ }
2535
+ });
2536
+
2432
2537
  // src/commands/vm/update.ts
2433
- import { Command as Command23 } from "commander";
2434
- var updateCommand = new Command23("update").description("move a box onto the current base image (its files stay; a running box restarts)").argument("<name>", "box name").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
2538
+ import { Command as Command26 } from "commander";
2539
+ var updateCommand = new Command26("update").description("move a box onto the current base image (its files stay; a running box restarts)").argument("<name>", "box name").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
2435
2540
  const client = await clientFor(cmd.optsWithGlobals());
2436
2541
  try {
2437
2542
  const before = pickRef(await boxesFor(client, name), name, me(client));
@@ -2453,8 +2558,8 @@ var updateCommand = new Command23("update").description("move a box onto the cur
2453
2558
  });
2454
2559
 
2455
2560
  // src/commands/vm/usage.ts
2456
- import { Command as Command24 } from "commander";
2457
- var usageCommand = new Command24("usage").description("how long a box ran, slept and sat stopped, as vCPU-hours, RAM and disk GiB-hours (and cost, when the host prices them)").argument("<name>", "box name").option("--since <date>", "count from this date instead of the box's creation, e.g. 2026-10-01").option("--json", "print as JSON").action(async (name, opts, cmd) => {
2561
+ import { Command as Command27 } from "commander";
2562
+ var usageCommand = new Command27("usage").description("how long a box ran, slept and sat stopped, as vCPU-hours, RAM and disk GiB-hours (and cost, when the host prices them)").argument("<name>", "box name").option("--since <date>", "count from this date instead of the box's creation, e.g. 2026-10-01").option("--json", "print as JSON").action(async (name, opts, cmd) => {
2458
2563
  let since;
2459
2564
  if (opts.since !== void 0) {
2460
2565
  const t = Date.parse(opts.since);
@@ -2501,8 +2606,8 @@ function block(u) {
2501
2606
  }
2502
2607
 
2503
2608
  // src/commands/vm/wake.ts
2504
- import { Command as Command25 } from "commander";
2505
- var wakeCommand = new Command25("wake").description("continue a hibernated box where it left off (same name, IP and disk)").argument("<name>", "box name").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
2609
+ import { Command as Command28 } from "commander";
2610
+ var wakeCommand = new Command28("wake").description("continue a hibernated box where it left off (same name, IP and disk)").argument("<name>", "box name").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
2506
2611
  const client = await clientFor(cmd.optsWithGlobals());
2507
2612
  try {
2508
2613
  const box = await spin(`waking ${name} (loading its memory from disk)\u2026`, client.wakeMachine(name));
@@ -2514,15 +2619,15 @@ var wakeCommand = new Command25("wake").description("continue a hibernated box w
2514
2619
  });
2515
2620
 
2516
2621
  // src/commands/vm/index.ts
2517
- var vmCommand = new Command26("vm").enablePositionalOptions().description("manage boxes (each one is a Firecracker microVM)").addCommand(newCommand).addCommand(forkCommand).addCommand(lsCommand).addCommand(getCommand).addCommand(connectCommand).addCommand(execCommand).addCommand(stopCommand).addCommand(startCommand).addCommand(pauseCommand).addCommand(resumeCommand).addCommand(hibernateCommand).addCommand(wakeCommand).addCommand(updateCommand).addCommand(rescaleCommand).addCommand(setCommand).addCommand(usageCommand).addCommand(topCommand).addCommand(proxyCommand).addCommand(rmCommand2);
2622
+ var vmCommand = new Command29("vm").enablePositionalOptions().description("manage boxes (each one is a Firecracker microVM)").addCommand(newCommand).addCommand(forkCommand).addCommand(lsCommand).addCommand(getCommand).addCommand(connectCommand).addCommand(execCommand).addCommand(stopCommand).addCommand(startCommand).addCommand(pauseCommand).addCommand(resumeCommand).addCommand(hibernateCommand).addCommand(wakeCommand).addCommand(updateCommand).addCommand(rescaleCommand).addCommand(setCommand).addCommand(usageCommand).addCommand(topCommand).addCommand(proxyCommand).addCommand(linkCommand).addCommand(unlinkCommand).addCommand(linksCommand).addCommand(rmCommand2);
2518
2623
  for (const cmd of vmCommand.commands) if (cmd !== proxyCommand) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
2519
2624
  var vmAliases = [newCommand, lsCommand, getCommand, connectCommand, execCommand, stopCommand, startCommand, pauseCommand, resumeCommand, hibernateCommand, wakeCommand, rmCommand2, claimCommand];
2520
2625
 
2521
2626
  // src/commands/server/index.ts
2522
- import { Command as Command34 } from "commander";
2627
+ import { Command as Command37 } from "commander";
2523
2628
 
2524
2629
  // src/commands/server/join.ts
2525
- import { Command as Command27 } from "commander";
2630
+ import { Command as Command30 } from "commander";
2526
2631
 
2527
2632
  // src/commands/server/daemon.ts
2528
2633
  import { spawn as spawn3 } from "child_process";
@@ -2576,7 +2681,7 @@ function runKvboxServer(args) {
2576
2681
  }
2577
2682
 
2578
2683
  // src/commands/server/join.ts
2579
- var joinCommand = new Command27("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)").action(async (url, opts) => {
2684
+ var joinCommand = new Command30("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)").action(async (url, opts) => {
2580
2685
  const args = ["join", url, "--token", opts.token];
2581
2686
  if (opts.advertise !== void 0) args.push("--advertise", opts.advertise);
2582
2687
  if (opts.name !== void 0) args.push("--name", opts.name);
@@ -2586,8 +2691,8 @@ var joinCommand = new Command27("join").description("put this machine behind a c
2586
2691
  });
2587
2692
 
2588
2693
  // src/commands/server/leave.ts
2589
- import { Command as Command28 } from "commander";
2590
- var leaveCommand = new Command28("leave").description("take this machine out from behind its control plane and restart its server").action(async () => {
2694
+ import { Command as Command31 } from "commander";
2695
+ var leaveCommand = new Command31("leave").description("take this machine out from behind its control plane and restart its server").action(async () => {
2591
2696
  const p = paths();
2592
2697
  for (const line of (await runKvboxServer(["leave"])).split("\n")) info(line);
2593
2698
  if (await runningPid(p) === null) return;
@@ -2596,14 +2701,14 @@ var leaveCommand = new Command28("leave").description("take this machine out fro
2596
2701
  });
2597
2702
 
2598
2703
  // src/commands/server/relay.ts
2599
- import { Command as Command29 } from "commander";
2600
- var relayCommand = new Command29("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) => {
2704
+ import { Command as Command32 } from "commander";
2705
+ var relayCommand = new Command32("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) => {
2601
2706
  for (const line of (await runKvboxServer(["relay", joinString])).split("\n")) info(line);
2602
2707
  });
2603
2708
 
2604
2709
  // src/commands/server/start.ts
2605
- import { Command as Command30 } from "commander";
2606
- var startCommand2 = new Command30("start").description("start the local kvbox-server in the background").action(async (_opts, cmd) => {
2710
+ import { Command as Command33 } from "commander";
2711
+ var startCommand2 = new Command33("start").description("start the local kvbox-server in the background").action(async (_opts, cmd) => {
2607
2712
  const client = await clientFor({ ...cmd.optsWithGlobals(), local: true }, { autoStart: false });
2608
2713
  try {
2609
2714
  const health = await client.health();
@@ -2619,8 +2724,8 @@ var startCommand2 = new Command30("start").description("start the local kvbox-se
2619
2724
  });
2620
2725
 
2621
2726
  // src/commands/server/status.ts
2622
- import { Command as Command31 } from "commander";
2623
- var statusCommand = new Command31("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) => {
2727
+ import { Command as Command34 } from "commander";
2728
+ var statusCommand = new Command34("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) => {
2624
2729
  const client = await clientFor({ ...cmd.optsWithGlobals(), local: true });
2625
2730
  try {
2626
2731
  const health = await client.health();
@@ -2652,8 +2757,8 @@ var statusCommand = new Command31("status").description("show whether this machi
2652
2757
  });
2653
2758
 
2654
2759
  // src/commands/server/stop.ts
2655
- import { Command as Command32 } from "commander";
2656
- var stopCommand2 = new Command32("stop").description("stop the local server (running boxes are not affected)").action(async () => {
2760
+ import { Command as Command35 } from "commander";
2761
+ var stopCommand2 = new Command35("stop").description("stop the local server (running boxes are not affected)").action(async () => {
2657
2762
  const pid = await runningPid(paths());
2658
2763
  if (pid === null) throw new KvboxError("kvbox-server is not running");
2659
2764
  await stopLocalServer(pid);
@@ -2661,8 +2766,8 @@ var stopCommand2 = new Command32("stop").description("stop the local server (run
2661
2766
  });
2662
2767
 
2663
2768
  // src/commands/server/trust-ca.ts
2664
- import { Command as Command33 } from "commander";
2665
- var trustCaCommand = new Command33("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) => {
2769
+ import { Command as Command36 } from "commander";
2770
+ var trustCaCommand = new Command36("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) => {
2666
2771
  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");
2667
2772
  if (publicKey !== void 0 && opts.fromCloud) throw new KvboxError("either a public key or --from-cloud, not both");
2668
2773
  const client = await clientFor({ ...cmd.optsWithGlobals(), local: true });
@@ -2700,7 +2805,7 @@ function describeReport(report) {
2700
2805
  }
2701
2806
 
2702
2807
  // src/commands/server/index.ts
2703
- var serverCommand = new Command34("server").description("run or manage the kvbox server").addCommand(startCommand2).addCommand(statusCommand).addCommand(stopCommand2).addCommand(joinCommand).addCommand(leaveCommand).addCommand(relayCommand).addCommand(trustCaCommand);
2808
+ var serverCommand = new Command37("server").description("run or manage the kvbox server").addCommand(startCommand2).addCommand(statusCommand).addCommand(stopCommand2).addCommand(joinCommand).addCommand(leaveCommand).addCommand(relayCommand).addCommand(trustCaCommand);
2704
2809
 
2705
2810
  // src/commands/login.ts
2706
2811
  import { spawnSync as spawnSync3 } from "child_process";
@@ -2708,8 +2813,8 @@ import { mkdir as mkdir3, readFile as readFile5, writeFile as writeFile3 } from
2708
2813
  import { hostname as osHostname } from "os";
2709
2814
  import { createInterface as createInterface2 } from "readline/promises";
2710
2815
  import { Writable } from "stream";
2711
- import { Command as Command35 } from "commander";
2712
- var loginCommand = new Command35("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) => {
2816
+ import { Command as Command38 } from "commander";
2817
+ 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) => {
2713
2818
  const url = normalizeUrl(urlArg ?? DEFAULT_CLOUD_URL);
2714
2819
  const creds = await readCredentials(opts);
2715
2820
  const session = await runLogin(url, creds, paths());
@@ -2789,8 +2894,8 @@ async function firstLine(stream) {
2789
2894
  }
2790
2895
 
2791
2896
  // src/commands/logout.ts
2792
- import { Command as Command36 } from "commander";
2793
- var logoutCommand = new Command36("logout").description("log out of the control plane; commands target this machine's kvbox-server again").action(async () => {
2897
+ import { Command as Command39 } from "commander";
2898
+ var logoutCommand = new Command39("logout").description("log out of the control plane; commands target this machine's kvbox-server again").action(async () => {
2794
2899
  const p = paths();
2795
2900
  const session = await readSession(p).catch(() => null);
2796
2901
  switch (await runLogout(p)) {
@@ -2827,8 +2932,8 @@ async function runLogout(p = paths()) {
2827
2932
  }
2828
2933
 
2829
2934
  // src/commands/whoami.ts
2830
- import { Command as Command37 } from "commander";
2831
- var whoamiCommand = new Command37("whoami").description("show which account and control plane commands target (or local mode)").option("--json", "print as JSON").action(async (opts) => {
2935
+ import { Command as Command40 } from "commander";
2936
+ 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) => {
2832
2937
  const session = await readSession();
2833
2938
  if (opts.json) {
2834
2939
  json(session ? { user: session.user, url: session.url, sshCertExpires: session.sshCertExpires ?? null } : null);
@@ -2844,11 +2949,11 @@ function describeSession(session) {
2844
2949
  }
2845
2950
 
2846
2951
  // src/commands/snapshots/index.ts
2847
- import { Command as Command41 } from "commander";
2952
+ import { Command as Command44 } from "commander";
2848
2953
 
2849
2954
  // src/commands/snapshots/ls.ts
2850
- import { Command as Command38 } from "commander";
2851
- var lsCommand3 = new Command38("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) => {
2955
+ import { Command as Command41 } from "commander";
2956
+ var lsCommand3 = 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) => {
2852
2957
  const client = await clientFor(cmd.optsWithGlobals());
2853
2958
  try {
2854
2959
  const cloud = client.target.kind === "cloud";
@@ -2879,21 +2984,22 @@ var lsCommand3 = new Command38("ls").description("list snapshots (yours and your
2879
2984
  });
2880
2985
 
2881
2986
  // src/commands/snapshots/new.ts
2882
- import { Command as Command39 } from "commander";
2883
- var newCommand2 = new Command39("new").description("freeze a running box (memory + disk) into a snapshot; the box keeps running").argument("<box>", "box name").argument("<name>", "snapshot name").option("--json", "print the snapshot as JSON").action(async (box, name, opts, cmd) => {
2987
+ import { Command as Command42 } from "commander";
2988
+ 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) => {
2884
2989
  const client = await clientFor(cmd.optsWithGlobals());
2885
2990
  try {
2886
- const snap = await spin(`saving snapshot ${name} from box ${box} (memory + disk)\u2026`, client.createSnapshot({ box, name }));
2991
+ const req = { box, name, ...opts.replace ? { replace: true } : {} };
2992
+ const snap = await spin(`saving snapshot ${name} from box ${box} (memory + disk)\u2026`, client.createSnapshot(req));
2887
2993
  if (opts.json) json(snap);
2888
- else info(`${color.green("\u2713")} snapshot ${name} saved from box ${box} (${gb(snap.sizeBytes)} on disk); start a warm clone with: kvbox new --from ${name}`);
2994
+ else info(`${color.green("\u2713")} snapshot ${name} ${opts.replace ? "retaken" : "saved"} from box ${box} (${gb(snap.sizeBytes)} on disk); start a warm clone with: kvbox new --from ${name}`);
2889
2995
  } finally {
2890
2996
  await client.close();
2891
2997
  }
2892
2998
  });
2893
2999
 
2894
3000
  // src/commands/snapshots/rm.ts
2895
- import { Command as Command40 } from "commander";
2896
- var rmCommand3 = new Command40("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) => {
3001
+ import { Command as Command43 } from "commander";
3002
+ var rmCommand3 = 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) => {
2897
3003
  if (!await confirm(`Delete snapshot ${name}?`, opts.yes ?? false)) {
2898
3004
  info("cancelled");
2899
3005
  process.exitCode = 1;
@@ -2909,14 +3015,14 @@ var rmCommand3 = new Command40("rm").description("delete a snapshot (boxes made
2909
3015
  });
2910
3016
 
2911
3017
  // src/commands/snapshots/index.ts
2912
- var snapshotsCommand = new Command41("snapshots").aliases(["snapshot", "snap"]).description("freeze running boxes into snapshots and manage them").addCommand(newCommand2).addCommand(lsCommand3).addCommand(rmCommand3);
3018
+ var snapshotsCommand = new Command44("snapshots").aliases(["snapshot", "snap"]).description("freeze running boxes into snapshots and manage them").addCommand(newCommand2).addCommand(lsCommand3).addCommand(rmCommand3);
2913
3019
  for (const cmd of snapshotsCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
2914
3020
 
2915
3021
  // src/commands/org/index.ts
2916
- import { Command as Command47 } from "commander";
3022
+ import { Command as Command50 } from "commander";
2917
3023
 
2918
3024
  // src/commands/org/ls.ts
2919
- import { Command as Command42 } from "commander";
3025
+ import { Command as Command45 } from "commander";
2920
3026
 
2921
3027
  // src/commands/org/context.ts
2922
3028
  var NOT_LOGGED_IN = "orgs live on the control plane: kvbox login first";
@@ -2936,7 +3042,7 @@ function orgFor(opts, target) {
2936
3042
  }
2937
3043
 
2938
3044
  // src/commands/org/ls.ts
2939
- var lsCommand4 = new Command42("ls").description("list the orgs you belong to and your role in each").option("--json", "print as JSON").action(async (opts, cmd) => {
3045
+ var lsCommand4 = new Command45("ls").description("list the orgs you belong to and your role in each").option("--json", "print as JSON").action(async (opts, cmd) => {
2940
3046
  const client = await cloudClientFor(cmd.optsWithGlobals());
2941
3047
  try {
2942
3048
  const orgs = await client.listOrgs();
@@ -2958,8 +3064,8 @@ function orgRows(orgs) {
2958
3064
  }
2959
3065
 
2960
3066
  // src/commands/org/members.ts
2961
- import { Command as Command43, Option as Option4 } from "commander";
2962
- var lsCommand5 = new Command43("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) => {
3067
+ import { Command as Command46, Option as Option4 } from "commander";
3068
+ var lsCommand5 = 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) => {
2963
3069
  const client = await cloudClientFor(cmd.optsWithGlobals());
2964
3070
  try {
2965
3071
  const org = await client.getOrg(orgFor(opts, client.target));
@@ -2973,7 +3079,7 @@ var lsCommand5 = new Command43("ls").description("list an org's members and thei
2973
3079
  await client.close();
2974
3080
  }
2975
3081
  });
2976
- var addCommand2 = new Command43("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) => {
3082
+ 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) => {
2977
3083
  const client = await cloudClientFor(cmd.optsWithGlobals());
2978
3084
  try {
2979
3085
  const slug = orgFor(opts, client.target);
@@ -2983,7 +3089,7 @@ var addCommand2 = new Command43("add").description("add a user to an org (admins
2983
3089
  await client.close();
2984
3090
  }
2985
3091
  });
2986
- var rmCommand4 = new Command43("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) => {
3092
+ var rmCommand4 = 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) => {
2987
3093
  const client = await cloudClientFor(cmd.optsWithGlobals());
2988
3094
  try {
2989
3095
  const slug = orgFor(opts, client.target);
@@ -2999,11 +3105,11 @@ var rmCommand4 = new Command43("rm").description("remove a member (or leave: rem
2999
3105
  await client.close();
3000
3106
  }
3001
3107
  });
3002
- var membersCommand = new Command43("members").description("who is in an org and what they may do").addCommand(lsCommand5).addCommand(addCommand2).addCommand(rmCommand4);
3108
+ var membersCommand = new Command46("members").description("who is in an org and what they may do").addCommand(lsCommand5).addCommand(addCommand2).addCommand(rmCommand4);
3003
3109
 
3004
3110
  // src/commands/org/new.ts
3005
- import { Command as Command44 } from "commander";
3006
- var newCommand3 = new Command44("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) => {
3111
+ import { Command as Command47 } from "commander";
3112
+ 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) => {
3007
3113
  const client = await cloudClientFor(cmd.optsWithGlobals());
3008
3114
  try {
3009
3115
  const org = await client.createOrg({ slug, name: opts.name ?? slug });
@@ -3019,8 +3125,8 @@ var newCommand3 = new Command44("new").description("create an org; you become it
3019
3125
  });
3020
3126
 
3021
3127
  // src/commands/org/rm.ts
3022
- import { Command as Command45 } from "commander";
3023
- var rmCommand5 = new Command45("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) => {
3128
+ import { Command as Command48 } from "commander";
3129
+ var rmCommand5 = 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) => {
3024
3130
  if (!await confirm(`Delete org ${slug}? Its members lose access; its slug stays taken.`, opts.yes ?? false)) {
3025
3131
  info("cancelled");
3026
3132
  process.exitCode = 1;
@@ -3036,8 +3142,8 @@ var rmCommand5 = new Command45("rm").description("delete an org (owners only; re
3036
3142
  });
3037
3143
 
3038
3144
  // src/commands/org/role.ts
3039
- import { Argument, Command as Command46 } from "commander";
3040
- var roleCommand = new Command46("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) => {
3145
+ import { Argument, Command as Command49 } from "commander";
3146
+ 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) => {
3041
3147
  const client = await cloudClientFor(cmd.optsWithGlobals());
3042
3148
  try {
3043
3149
  const slug = orgFor(opts, client.target);
@@ -3049,10 +3155,10 @@ var roleCommand = new Command46("role").description("change a member's role (own
3049
3155
  });
3050
3156
 
3051
3157
  // src/commands/org/index.ts
3052
- var orgCommand = new Command47("org").description("orgs: shared slugs that own boxes, with owners, admins and members").addCommand(lsCommand4).addCommand(newCommand3).addCommand(membersCommand).addCommand(roleCommand).addCommand(rmCommand5);
3158
+ var orgCommand = new Command50("org").description("orgs: shared slugs that own boxes, with owners, admins and members").addCommand(lsCommand4).addCommand(newCommand3).addCommand(membersCommand).addCommand(roleCommand).addCommand(rmCommand5);
3053
3159
 
3054
3160
  // src/commands/usage.ts
3055
- import { Command as Command48 } from "commander";
3161
+ import { Command as Command51 } from "commander";
3056
3162
 
3057
3163
  // ../shared/src/usage.ts
3058
3164
  import { z as z4 } from "zod";
@@ -3089,7 +3195,7 @@ function sumUsage(items, pricing) {
3089
3195
  }
3090
3196
 
3091
3197
  // src/commands/usage.ts
3092
- var usageCommand2 = new Command48("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) => {
3198
+ 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) => {
3093
3199
  for (const [name, value] of [
3094
3200
  ["since", opts.since],
3095
3201
  ["until", opts.until]
@@ -3235,8 +3341,8 @@ function userRows(r) {
3235
3341
  }
3236
3342
 
3237
3343
  // src/commands/credit.ts
3238
- import { Command as Command49 } from "commander";
3239
- var creditCommand = new Command49("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) => {
3344
+ import { Command as Command52 } from "commander";
3345
+ 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) => {
3240
3346
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
3241
3347
  try {
3242
3348
  if (client.target.kind === "local") throw new KvboxError("credit lives on the control plane: kvbox login first");
@@ -3266,7 +3372,7 @@ function creditRow(b, me2) {
3266
3372
  // src/commands/deploy/index.ts
3267
3373
  import { readFile as readFile7 } from "fs/promises";
3268
3374
  import { basename, resolve as resolve2 } from "path";
3269
- import { Command as Command50, Option as Option5 } from "commander";
3375
+ import { Command as Command53, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
3270
3376
 
3271
3377
  // src/commands/deploy/config.ts
3272
3378
  import { readFile as readFile6, writeFile as writeFile4 } from "fs/promises";
@@ -3287,10 +3393,12 @@ function runScript(pm, script) {
3287
3393
  return pm === "yarn" ? [script] : ["run", script];
3288
3394
  }
3289
3395
 
3290
- // src/commands/deploy/templates/nextjs.ts
3396
+ // src/commands/deploy/templates/server.ts
3291
3397
  var APP_DIR = "/srv/app/current";
3292
3398
  var SERVICE = "kvbox-app";
3293
- var PORT = 3e3;
3399
+ var START_WAIT_SEC = 30;
3400
+ var APP_NOT_LISTENING = 4;
3401
+ var LOG_MARKER = "--- kvbox-app log ---";
3294
3402
  function commands(pm) {
3295
3403
  switch (pm) {
3296
3404
  case "pnpm":
@@ -3303,12 +3411,67 @@ function commands(pm) {
3303
3411
  return { setup: [], install: "if [ -f package-lock.json ]; then npm ci; else npm install; fi", build: "npm run build", start: "npm run start" };
3304
3412
  }
3305
3413
  }
3414
+ function serverRemote(opts) {
3415
+ const c = commands(opts.pm);
3416
+ const unit = [
3417
+ "[Unit]",
3418
+ "Description=kvbox deploy: the app in " + APP_DIR,
3419
+ "After=network.target",
3420
+ "",
3421
+ "[Service]",
3422
+ "User=kvbox",
3423
+ `WorkingDirectory=${APP_DIR}`,
3424
+ // PORT on the command line: the proxied address points at it, and nothing in the environment
3425
+ // file below may move the app off it (env's PORT, say, copied from a .env).
3426
+ `ExecStart=/usr/bin/env PORT=${opts.port} ${c.start}`,
3427
+ "Environment=NODE_ENV=production",
3428
+ // The box owner's variables (#88, base v0.10.0+; the `-` makes an older box start without them).
3429
+ "EnvironmentFile=-/etc/kvbox/env",
3430
+ "Restart=always",
3431
+ "RestartSec=2",
3432
+ "",
3433
+ "[Install]",
3434
+ "WantedBy=multi-user.target"
3435
+ ];
3436
+ return [
3437
+ "set -e",
3438
+ "test -d /srv/app -a -w /srv/app || exit 3",
3439
+ "rm -rf /srv/app/.incoming /srv/app/.old",
3440
+ "mkdir -p /srv/app/.incoming",
3441
+ "tar -xf - -C /srv/app/.incoming",
3442
+ "cd /srv/app/.incoming",
3443
+ // Not NODE_ENV=production here: the install would skip devDependencies, which the build needs (TypeScript, Tailwind).
3444
+ `export ${["CI=1", ...opts.env ?? []].join(" ")}`,
3445
+ ...c.setup,
3446
+ c.install,
3447
+ ...opts.build ? [c.build] : [],
3448
+ "cd /",
3449
+ `sudo -n tee /etc/systemd/system/${SERVICE}.service >/dev/null <<'UNIT'`,
3450
+ ...unit,
3451
+ "UNIT",
3452
+ `if [ -e ${APP_DIR} ]; then mv ${APP_DIR} /srv/app/.old; fi`,
3453
+ `mv /srv/app/.incoming ${APP_DIR}`,
3454
+ "sudo -n systemctl daemon-reload",
3455
+ `sudo -n systemctl enable --quiet ${SERVICE}`,
3456
+ `sudo -n systemctl restart ${SERVICE}`,
3457
+ "rm -rf /srv/app/.old",
3458
+ // bash's /dev/tcp: no curl or nc in the image needed.
3459
+ "i=0",
3460
+ `until timeout 1 bash -c '</dev/tcp/127.0.0.1/${opts.port}' 2>/dev/null; do`,
3461
+ " i=$((i+1))",
3462
+ ` if [ "$i" -ge ${START_WAIT_SEC} ]; then echo '${LOG_MARKER}'; sudo -n journalctl -u ${SERVICE} -n 20 --no-pager -o cat || true; exit ${APP_NOT_LISTENING}; fi`,
3463
+ " sleep 1",
3464
+ "done"
3465
+ ].join("\n");
3466
+ }
3467
+
3468
+ // src/commands/deploy/templates/nextjs.ts
3306
3469
  var nextjsTemplate = {
3307
3470
  id: "nextjs",
3308
3471
  label: "Next.js",
3309
3472
  hint: "source shipped; installed, built and run in the box on port 3000",
3310
3473
  size: "s",
3311
- port: PORT,
3474
+ port: 3e3,
3312
3475
  detect(pkg) {
3313
3476
  if (!pkg) return false;
3314
3477
  return "next" in { ...pkg.dependencies, ...pkg.devDependencies };
@@ -3319,60 +3482,37 @@ var nextjsTemplate = {
3319
3482
  if (typeof ctx.pkg?.scripts?.[script] !== "string") throw new KvboxError(`${ctx.dir}: package.json has no "${script}" script; Next.js needs "build": "next build" and "start": "next start"`);
3320
3483
  }
3321
3484
  const pm = await packageManager(ctx.dir);
3322
- return { outDir: ctx.dir, exclude: ["node_modules", ".next", ".git"], pm, what: "the source" };
3485
+ return { outDir: ctx.dir, exclude: ["node_modules", ".next", ".git"], pm, what: "the source", boxBuild: true };
3323
3486
  },
3324
- /**
3325
- * The source lands in a staging directory and is installed and built there while the old app
3326
- * keeps serving; only then is it swapped into place and the service restarted, so a failed
3327
- * install or build leaves the running app alone. The unit is rewritten every time, so a changed
3328
- * package manager or start script takes effect. /srv/app is the kvbox user's (image v0.8.0+). The
3329
- * build runs in the deploy's SSH session, so it sees the owner's variables (`kvbox env`) too.
3330
- */
3331
- remote(built) {
3332
- const c = commands(built.pm);
3333
- const unit = [
3334
- "[Unit]",
3335
- "Description=kvbox deploy: the app in " + APP_DIR,
3336
- "After=network.target",
3337
- "",
3338
- "[Service]",
3339
- "User=kvbox",
3340
- `WorkingDirectory=${APP_DIR}`,
3341
- // PORT on the command line: the proxied address points at it, and nothing in the environment
3342
- // file below may move the app off it (env's PORT, say, copied from a .env).
3343
- `ExecStart=/usr/bin/env PORT=${PORT} ${c.start}`,
3344
- "Environment=NODE_ENV=production",
3345
- // The box owner's variables (#88, base v0.10.0+; the `-` makes an older box start without them).
3346
- "EnvironmentFile=-/etc/kvbox/env",
3347
- "Restart=always",
3348
- "RestartSec=2",
3349
- "",
3350
- "[Install]",
3351
- "WantedBy=multi-user.target"
3352
- ];
3353
- return [
3354
- "set -e",
3355
- "test -d /srv/app -a -w /srv/app || exit 3",
3356
- "rm -rf /srv/app/.incoming /srv/app/.old",
3357
- "mkdir -p /srv/app/.incoming",
3358
- "tar -xf - -C /srv/app/.incoming",
3359
- "cd /srv/app/.incoming",
3360
- // Not NODE_ENV=production here: the install would skip devDependencies, which the build needs (TypeScript, Tailwind).
3361
- "export CI=1 NEXT_TELEMETRY_DISABLED=1",
3362
- ...c.setup,
3363
- c.install,
3364
- c.build,
3365
- "cd /",
3366
- `sudo -n tee /etc/systemd/system/${SERVICE}.service >/dev/null <<'UNIT'`,
3367
- ...unit,
3368
- "UNIT",
3369
- `if [ -e ${APP_DIR} ]; then mv ${APP_DIR} /srv/app/.old; fi`,
3370
- `mv /srv/app/.incoming ${APP_DIR}`,
3371
- "sudo -n systemctl daemon-reload",
3372
- `sudo -n systemctl enable --quiet ${SERVICE}`,
3373
- `sudo -n systemctl restart ${SERVICE}`,
3374
- "rm -rf /srv/app/.old"
3375
- ].join("\n");
3487
+ remote(built, port) {
3488
+ return serverRemote({ pm: built.pm, port, build: true, env: ["NEXT_TELEMETRY_DISABLED=1"] });
3489
+ }
3490
+ };
3491
+
3492
+ // src/commands/deploy/templates/node.ts
3493
+ var FRAMEWORKS = ["express", "fastify", "koa", "@nestjs/core", "@hono/node-server"];
3494
+ var nodeTemplate = {
3495
+ id: "node",
3496
+ label: "Node server",
3497
+ hint: "Express, Fastify, Hono, NestJS\u2026: installed and run in the box on $PORT (3000)",
3498
+ size: "xs",
3499
+ port: 3e3,
3500
+ customPort: true,
3501
+ detect(pkg) {
3502
+ if (!pkg) return false;
3503
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
3504
+ return FRAMEWORKS.some((f) => f in deps);
3505
+ },
3506
+ async build(ctx) {
3507
+ if (typeof ctx.pkg?.scripts?.["start"] !== "string") {
3508
+ throw new KvboxError(`${ctx.dir}: package.json has no "start" script; the box runs it to start the server (for example "start": "node server.js")`);
3509
+ }
3510
+ const pm = await packageManager(ctx.dir);
3511
+ const boxBuild = typeof ctx.pkg.scripts["build"] === "string";
3512
+ return { outDir: ctx.dir, exclude: ["node_modules", ".git"], pm, what: "the source", boxBuild };
3513
+ },
3514
+ remote(built, port) {
3515
+ return serverRemote({ pm: built.pm, port, build: built.boxBuild === true });
3376
3516
  }
3377
3517
  };
3378
3518
 
@@ -3442,7 +3582,7 @@ var reactTemplate = {
3442
3582
  };
3443
3583
 
3444
3584
  // src/commands/deploy/templates/index.ts
3445
- var TEMPLATES = [reactTemplate, nextjsTemplate];
3585
+ var TEMPLATES = [reactTemplate, nextjsTemplate, nodeTemplate];
3446
3586
  var TEMPLATE_IDS = TEMPLATES.map((t) => t.id);
3447
3587
  function templateById(id) {
3448
3588
  const t = TEMPLATES.find((x) => x.id === id);
@@ -3469,7 +3609,9 @@ var DeployConfigSchema = z5.object({
3469
3609
  }).optional(),
3470
3610
  size: z5.enum(SIZE_NAMES).optional(),
3471
3611
  /** The build output directory, relative to the app; the template's default when absent. */
3472
- dist: z5.string().optional()
3612
+ dist: z5.string().optional(),
3613
+ /** The port the app serves, for a Node server that hardcodes one; the template's (3000) when absent. */
3614
+ port: z5.number().int().min(1).max(65535).optional()
3473
3615
  });
3474
3616
  async function readConfig(dir) {
3475
3617
  const path = join4(dir, CONFIG_FILE);
@@ -3558,7 +3700,7 @@ async function ship(ep, dir, remote, exclude = []) {
3558
3700
  var shipping = { ship, measure, waitForSsh };
3559
3701
 
3560
3702
  // src/commands/deploy/index.ts
3561
- var deployCommand = new Command50("deploy").description("put the app in this directory (React or Next.js) 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 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("-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) => {
3703
+ var deployCommand = new Command53("deploy").description("put the app in this directory (React, Next.js or a Node server) 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 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 port a Node server listens on, when it does not use $PORT (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) => {
3562
3704
  const dir = resolve2(dirArg ?? ".");
3563
3705
  const pkg = await readPackageJson(dir);
3564
3706
  const saved = await readConfig(dir);
@@ -3585,8 +3727,10 @@ var deployCommand = new Command50("deploy").description("put the app in this dir
3585
3727
  const box = created || wasRunning ? found : await wakeUp(client, found, ref);
3586
3728
  const ep = sshEndpoint(box, client.target);
3587
3729
  if (!wasRunning) await spin(`waiting for ${ref} to accept SSH\u2026`, shipping.waitForSsh(ep));
3588
- const shipIt = () => shipping.ship(ep, built.outDir, template.remote(built), built.exclude);
3589
- const doing = built.dist === void 0 ? `shipping ${built.what} (${size.files} files, ${gb(size.bytes)}) to ${ref} and building there, a minute or two\u2026` : `shipping ${built.what} (${size.files} files, ${gb(size.bytes)}) to ${ref}\u2026`;
3730
+ const port = config.port ?? template.port;
3731
+ const shipIt = () => shipping.ship(ep, built.outDir, template.remote(built, port), built.exclude);
3732
+ const there = built.boxBuild ? "installing and building there" : "installing there";
3733
+ const doing = built.dist === void 0 ? `shipping ${built.what} (${size.files} files, ${gb(size.bytes)}) to ${ref} and ${there}, a minute or two\u2026` : `shipping ${built.what} (${size.files} files, ${gb(size.bytes)}) to ${ref}\u2026`;
3590
3734
  let result = await spin(doing, shipIt);
3591
3735
  if (result.status === SSH_FAILED3 && await renewAfterRefusal(client, cert, box.owner)) {
3592
3736
  info("renewed your SSH certificate, trying again\u2026");
@@ -3599,11 +3743,19 @@ ${result.output.trim()}` : ""}`, SSH_FAILED3);
3599
3743
  `box ${ref} runs an image too old for the ${template.label} template (base v0.8.0 or newer). Update the box (kvbox vm update ${ref}) once its host has the new image, or deploy under another name (--name) to get a fresh box`
3600
3744
  );
3601
3745
  }
3746
+ if (result.status === APP_NOT_LISTENING) {
3747
+ const log = result.output.split(LOG_MARKER)[1]?.trim();
3748
+ throw new KvboxError(
3749
+ `the app did not answer on port ${port} within ${START_WAIT_SEC} s: it crashed, or listens on another port. It must listen on process.env.PORT (${port})${template.customPort ? ", or say its port with --port" : ""}. Its log: kvbox exec ${ref} -- journalctl -u kvbox-app${log ? `
3750
+ last lines:
3751
+ ${log}` : ""}`
3752
+ );
3753
+ }
3602
3754
  if (result.status !== 0) throw new KvboxError(`deploying to ${ref} failed (exit ${result.status}):
3603
3755
  ${result.output.trim()}`);
3604
- let url = `http://${box.ip}`;
3756
+ let url = `http://${box.ip}${port === 80 ? "" : `:${port}`}`;
3605
3757
  if (cloud) {
3606
- const got = await address(client, box, ref, config, template);
3758
+ const got = await address(client, box, ref, config, port);
3607
3759
  url = got.url;
3608
3760
  if (got.subdomain !== config.subdomain) await writeConfig(dir, { ...config, subdomain: got.subdomain, ...built.dist !== void 0 && built.dist !== config.dist ? { dist: built.dist } : {} });
3609
3761
  }
@@ -3620,6 +3772,11 @@ ${result.output.trim()}`);
3620
3772
  await client.close();
3621
3773
  }
3622
3774
  });
3775
+ function parsePort(v) {
3776
+ const n = Number(v);
3777
+ if (!Number.isInteger(n) || n < 1 || n > 65535) throw new InvalidArgumentError2("expected a port, 1-65535");
3778
+ return n;
3779
+ }
3623
3780
  async function readPackageJson(dir) {
3624
3781
  try {
3625
3782
  return JSON.parse(await readFile7(resolve2(dir, "package.json"), "utf8"));
@@ -3663,7 +3820,7 @@ async function settle(dir, pkg, saved, opts, orgFlag, cloud) {
3663
3820
  const initial = detected ? TEMPLATES.indexOf(detected) : 0;
3664
3821
  templateId = await select("Template", TEMPLATES.map((t) => ({ value: t.id, label: t.label, hint: t === detected ? `${t.hint} \xB7 detected` : t.hint })), initial);
3665
3822
  }
3666
- if (templateId === void 0) throw new KvboxError(`could not tell what kind of app ${dir} is (no package.json of a Vite, Create React App or Next.js project): say it with --template ${TEMPLATE_IDS.join("|")}`);
3823
+ if (templateId === void 0) throw new KvboxError(`could not tell what kind of app ${dir} is (no package.json of a Vite, Create React App or Next.js project, or of a server on Express, Fastify, Koa, Hono or NestJS): say it with --template ${TEMPLATE_IDS.join("|")}`);
3667
3824
  const template = templateById(templateId);
3668
3825
  let name = defaults.name;
3669
3826
  if (open.name && ask) name = await text("Box name", { default: defaults.name, validate: (a) => BOX_NAME_RE.test(a) ? void 0 : NAME_RULE });
@@ -3682,6 +3839,8 @@ async function settle(dir, pkg, saved, opts, orgFlag, cloud) {
3682
3839
  if (open.size && ask) {
3683
3840
  size = await select("Box size", SIZE_NAMES.map((s) => ({ value: s, label: s, hint: `${SIZES[s].vcpu} vCPU, ${SIZES[s].memMib / 1024} GB RAM, ${SIZES[s].diskGib} GB disk` })), SIZE_NAMES.indexOf(template.size));
3684
3841
  }
3842
+ if (opts.port !== void 0 && !template.customPort) throw new KvboxError(`--port is for a Node server; the ${template.label} template serves port ${template.port}`);
3843
+ const port = opts.port ?? (template.customPort ? saved?.port : void 0);
3685
3844
  const org = orgFlag ?? saved?.org;
3686
3845
  const config = {
3687
3846
  template: template.id,
@@ -3689,7 +3848,8 @@ async function settle(dir, pkg, saved, opts, orgFlag, cloud) {
3689
3848
  ...org !== void 0 ? { org } : {},
3690
3849
  ...subdomain !== void 0 ? { subdomain } : {},
3691
3850
  size,
3692
- ...saved?.dist !== void 0 ? { dist: saved.dist } : {}
3851
+ ...saved?.dist !== void 0 ? { dist: saved.dist } : {},
3852
+ ...port !== void 0 ? { port } : {}
3693
3853
  };
3694
3854
  return { config, template, fresh };
3695
3855
  }
@@ -3719,15 +3879,15 @@ async function refuseOtherAddress(client, config) {
3719
3879
  `box ${ref} already answers at ${have.url}, not ${config.subdomain}. To keep the address: kvbox deploy --sub ${have.subdomain}. To move it: kvbox vm proxy release ${ref}, then deploy again`
3720
3880
  );
3721
3881
  }
3722
- async function address(client, box, ref, config, template) {
3882
+ async function address(client, box, ref, config, port) {
3723
3883
  const have = (await client.listSubdomains()).find((s) => s.box === box.name && s.owner === slugOf(box.owner));
3724
3884
  if (have) {
3725
- if (have.port !== template.port) await client.setSubdomainPort(ref, { port: template.port });
3885
+ if (have.port !== port) await client.setSubdomainPort(ref, { port });
3726
3886
  return { url: have.url, subdomain: have.subdomain };
3727
3887
  }
3728
3888
  const wanted = config.subdomain ?? subdomainFor(config.name);
3729
3889
  try {
3730
- const sub = await spin(`claiming https://${wanted}.kvbox.app\u2026`, client.claimSubdomain(ref, { name: wanted, port: template.port }));
3890
+ const sub = await spin(`claiming https://${wanted}.kvbox.app\u2026`, client.claimSubdomain(ref, { name: wanted, port }));
3731
3891
  return { url: sub.url, subdomain: sub.subdomain };
3732
3892
  } catch (err) {
3733
3893
  if (!(err instanceof KvboxError)) throw err;
@@ -3737,15 +3897,15 @@ the app is on box ${ref} but has no address yet: pick another with kvbox deploy
3737
3897
  }
3738
3898
 
3739
3899
  // src/commands/volume/index.ts
3740
- import { Command as Command56 } from "commander";
3900
+ import { Command as Command59 } from "commander";
3741
3901
 
3742
3902
  // src/commands/volume/attach.ts
3743
- import { Command as Command51 } from "commander";
3903
+ import { Command as Command54 } from "commander";
3744
3904
  function describeMount(machine, volume, box) {
3745
3905
  const path = machine.volumes?.find((v) => volume === v.name || volume.endsWith(`/${v.name}`))?.mountPath ?? volumeMountPath(volume.slice(volume.lastIndexOf("/") + 1));
3746
3906
  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`;
3747
3907
  }
3748
- var attachCommand = new Command51("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) => {
3908
+ 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) => {
3749
3909
  if (volumeArg === void 0 || boxArg === void 0) askOrUsage("give the volume and the box: kvbox volume attach <volume> <box>");
3750
3910
  const client = await clientFor(cmd.optsWithGlobals());
3751
3911
  try {
@@ -3764,7 +3924,7 @@ var attachCommand = new Command51("attach").description("attach a volume to a bo
3764
3924
  });
3765
3925
 
3766
3926
  // src/commands/volume/create.ts
3767
- import { Command as Command52 } from "commander";
3927
+ import { Command as Command55 } from "commander";
3768
3928
  function parseGib2(text2) {
3769
3929
  const mib = parseMib(text2);
3770
3930
  if (mib === void 0 || mib % 1024 !== 0) throw new KvboxError(`--size ${text2}: write whole GB, like 50 or 50GB`);
@@ -3780,7 +3940,7 @@ function sizeProblem(answer) {
3780
3940
  return err instanceof KvboxError ? err.message.replace(/^--size \S+: /, "") : String(err);
3781
3941
  }
3782
3942
  }
3783
- var createCommand = new Command52("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) => {
3943
+ var createCommand = 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) => {
3784
3944
  const ask = interactive();
3785
3945
  if (nameArg === void 0 || opts.size === void 0) askOrUsage("give the name and the size: kvbox volume create <name> --size <gb> --box <box>");
3786
3946
  const name = nameArg ?? await text("Volume name", { validate: (a) => VOLUME_NAME_RE.test(a) ? void 0 : VOLUME_NAME_RULE });
@@ -3813,8 +3973,8 @@ var createCommand = new Command52("create").alias("new").description("create a v
3813
3973
  });
3814
3974
 
3815
3975
  // src/commands/volume/detach.ts
3816
- import { Command as Command53 } from "commander";
3817
- var detachCommand = new Command53("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) => {
3976
+ import { Command as Command56 } from "commander";
3977
+ 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) => {
3818
3978
  if (volumeArg === void 0) askOrUsage("give the volume: kvbox volume detach <volume> [box]");
3819
3979
  const client = await clientFor(cmd.optsWithGlobals());
3820
3980
  try {
@@ -3839,8 +3999,8 @@ var detachCommand = new Command53("detach").description("detach a volume from a
3839
3999
  });
3840
4000
 
3841
4001
  // src/commands/volume/ls.ts
3842
- import { Command as Command54 } from "commander";
3843
- var lsCommand6 = new Command54("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) => {
4002
+ import { Command as Command57 } from "commander";
4003
+ var lsCommand6 = 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) => {
3844
4004
  const client = await clientFor(cmd.optsWithGlobals());
3845
4005
  try {
3846
4006
  const cloud = client.target.kind === "cloud";
@@ -3871,8 +4031,8 @@ var lsCommand6 = new Command54("ls").alias("list").description("list volumes: si
3871
4031
  });
3872
4032
 
3873
4033
  // src/commands/volume/rm.ts
3874
- import { Command as Command55 } from "commander";
3875
- var rmCommand6 = new Command55("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) => {
4034
+ import { Command as Command58 } from "commander";
4035
+ var rmCommand6 = 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) => {
3876
4036
  if (!await confirm(`Delete volume ${name} and everything on it?`, opts.yes ?? false)) {
3877
4037
  info("cancelled");
3878
4038
  process.exitCode = 1;
@@ -3888,14 +4048,14 @@ var rmCommand6 = new Command55("rm").alias("remove").description("delete a volum
3888
4048
  });
3889
4049
 
3890
4050
  // src/commands/volume/index.ts
3891
- var volumeCommand = new Command56("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(createCommand).addCommand(lsCommand6).addCommand(attachCommand).addCommand(detachCommand).addCommand(rmCommand6);
4051
+ 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(createCommand).addCommand(lsCommand6).addCommand(attachCommand).addCommand(detachCommand).addCommand(rmCommand6);
3892
4052
  for (const cmd of volumeCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
3893
4053
 
3894
4054
  // src/commands/env/index.ts
3895
- import { Command as Command60 } from "commander";
4055
+ import { Command as Command63 } from "commander";
3896
4056
 
3897
4057
  // src/commands/env/ls.ts
3898
- import { Command as Command57 } from "commander";
4058
+ import { Command as Command60 } from "commander";
3899
4059
 
3900
4060
  // src/commands/env/shared.ts
3901
4061
  function requireCloud2(client) {
@@ -3908,7 +4068,7 @@ function reach(boxes, verb) {
3908
4068
  }
3909
4069
 
3910
4070
  // src/commands/env/ls.ts
3911
- var lsCommand7 = new Command57("ls").alias("list").description("list the variables (a secret shows as (sealed))").option("--json", "print as JSON").action(async (opts, cmd) => {
4071
+ var lsCommand7 = new Command60("ls").alias("list").description("list the variables (a secret shows as (sealed))").option("--json", "print as JSON").action(async (opts, cmd) => {
3912
4072
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
3913
4073
  try {
3914
4074
  const owner = requireCloud2(client);
@@ -3928,8 +4088,8 @@ var lsCommand7 = new Command57("ls").alias("list").description("list the variabl
3928
4088
  });
3929
4089
 
3930
4090
  // src/commands/env/rm.ts
3931
- import { Command as Command58 } from "commander";
3932
- var rmCommand7 = new Command58("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("--json", "print as JSON").action(async (names, opts, cmd) => {
4091
+ import { Command as Command61 } from "commander";
4092
+ var rmCommand7 = 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("--json", "print as JSON").action(async (names, opts, cmd) => {
3933
4093
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
3934
4094
  try {
3935
4095
  const owner = requireCloud2(client);
@@ -3959,7 +4119,7 @@ var rmCommand7 = new Command58("rm").alias("remove").description("remove variabl
3959
4119
  });
3960
4120
 
3961
4121
  // src/commands/env/set.ts
3962
- import { Command as Command59 } from "commander";
4122
+ import { Command as Command62 } from "commander";
3963
4123
 
3964
4124
  // ../shared/src/env.ts
3965
4125
  var ENV_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
@@ -3978,7 +4138,7 @@ function envValueProblem(value) {
3978
4138
  }
3979
4139
 
3980
4140
  // src/commands/env/set.ts
3981
- var setCommand2 = new Command59("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("--json", "print as JSON").action(async (nameArg, valueArg, opts, cmd) => {
4141
+ 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("--json", "print as JSON").action(async (nameArg, valueArg, opts, cmd) => {
3982
4142
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
3983
4143
  try {
3984
4144
  const owner = requireCloud2(client);
@@ -4003,14 +4163,14 @@ var setCommand2 = new Command59("set").description("add or change a variable; bo
4003
4163
  });
4004
4164
 
4005
4165
  // src/commands/env/index.ts
4006
- var envCommand = new Command60("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand7, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand7);
4166
+ var envCommand = new Command63("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand7, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand7);
4007
4167
  for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
4008
4168
 
4009
4169
  // src/commands/domain/index.ts
4010
- import { Command as Command64 } from "commander";
4170
+ import { Command as Command67 } from "commander";
4011
4171
 
4012
4172
  // src/commands/domain/add.ts
4013
- import { Command as Command61 } from "commander";
4173
+ import { Command as Command64 } from "commander";
4014
4174
 
4015
4175
  // src/commands/domain/shared.ts
4016
4176
  function requireCloud3(client) {
@@ -4020,9 +4180,17 @@ var boxOf2 = (d, user) => user !== void 0 && d.owner !== user ? `${d.owner}/${d.
4020
4180
  function domainJson(d, user) {
4021
4181
  return { domain: d.domain, box: boxOf2(d, user), port: d.port, status: d.status, www: d.www, url: d.url, error: d.error, records: d.records, createdAt: d.createdAt };
4022
4182
  }
4183
+ function zoneOf(domain) {
4184
+ const labels = domain.split(".");
4185
+ const n = labels.length > 2 && labels.at(-1).length === 2 && labels.at(-2).length <= 3 ? 3 : 2;
4186
+ return labels.slice(-n).join(".");
4187
+ }
4188
+ function hostIn(name, zone) {
4189
+ return name === zone ? "@" : name.endsWith(`.${zone}`) ? name.slice(0, -(zone.length + 1)) : name;
4190
+ }
4023
4191
 
4024
4192
  // src/commands/domain/add.ts
4025
- var addCommand3 = new Command61("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) => {
4193
+ 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) => {
4026
4194
  const domain = assertDomain(domainArg.trim().toLowerCase());
4027
4195
  const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
4028
4196
  const client = await clientFor(cmd.optsWithGlobals());
@@ -4041,10 +4209,11 @@ var addCommand3 = new Command61("add").description("serve a box at a domain of y
4041
4209
  return;
4042
4210
  }
4043
4211
  info(`${color.green("\u2713")} ${domain} added for box ${color.bold(box)} port ${d.port}, waiting for its DNS`);
4212
+ const zone = zoneOf(domain);
4044
4213
  info(`
4045
- At the company that runs the DNS of ${domain}, add:
4214
+ At the company that runs the DNS of ${zone}, add:
4046
4215
  `);
4047
- table(d.records.map((r) => ({ type: r.type, name: r.name, value: r.value })));
4216
+ table(d.records.map((r) => ({ type: r.type, host: hostIn(r.name, zone), value: r.value })));
4048
4217
  info(`
4049
4218
  (the TXT record shows ${domain} is yours; keep it, it is checked again if the domain ever goes back to pending)`);
4050
4219
  if (d.records.some((r) => r.type === "CNAME")) info(` (the www record is optional: with it, www.${domain} serves the same site)`);
@@ -4057,8 +4226,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
4057
4226
  });
4058
4227
 
4059
4228
  // src/commands/domain/ls.ts
4060
- import { Command as Command62 } from "commander";
4061
- var lsCommand8 = new Command62("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
4229
+ import { Command as Command65 } from "commander";
4230
+ var lsCommand8 = new Command65("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
4062
4231
  const client = await clientFor(cmd.optsWithGlobals());
4063
4232
  try {
4064
4233
  requireCloud3(client);
@@ -4087,8 +4256,8 @@ var lsCommand8 = new Command62("ls").alias("list").description("list your custom
4087
4256
  });
4088
4257
 
4089
4258
  // src/commands/domain/rm.ts
4090
- import { Command as Command63 } from "commander";
4091
- var rmCommand8 = new Command63("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) => {
4259
+ import { Command as Command66 } from "commander";
4260
+ var rmCommand8 = 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) => {
4092
4261
  const domain = domainArg.trim().toLowerCase();
4093
4262
  const client = await clientFor(cmd.optsWithGlobals());
4094
4263
  try {
@@ -4109,12 +4278,12 @@ var rmCommand8 = new Command63("rm").alias("remove").description("stop serving a
4109
4278
  });
4110
4279
 
4111
4280
  // src/commands/domain/index.ts
4112
- var domainCommand = new Command64("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand3).addCommand(lsCommand8).addCommand(rmCommand8);
4281
+ var domainCommand = new Command67("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand3).addCommand(lsCommand8).addCommand(rmCommand8);
4113
4282
  for (const cmd of domainCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
4114
4283
 
4115
4284
  // src/program.ts
4116
4285
  function buildProgram() {
4117
- const program = new Command65("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();
4286
+ const program = new Command68("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();
4118
4287
  program.addCommand(vmCommand);
4119
4288
  program.addCommand(snapshotsCommand);
4120
4289
  program.addCommand(volumeCommand);