@kvbox/cli 0.5.28 → 0.5.30

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 Command68 } from "commander";
152
+ import { Command as Command72 } 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.28" : void 0);
167
+ var VERSION = versionOf(import.meta.url, true ? "0.5.30" : void 0);
168
168
 
169
169
  // src/commands/vm/index.ts
170
- import { Command as Command29 } from "commander";
170
+ import { Command as Command33 } from "commander";
171
171
 
172
172
  // src/commands/vm/connect.ts
173
173
  import { spawnSync as spawnSync2 } from "child_process";
@@ -217,6 +217,16 @@ function paths(home = kvboxHome()) {
217
217
  /** Symlink to the current base image, assets/rootfs-<version>.ext4; boxes keep using the version they were made from. */
218
218
  rootfs: join(home, "assets", "rootfs.ext4"),
219
219
  baseImage: (version) => join(home, "assets", `rootfs-${version}.ext4`),
220
+ /**
221
+ * Every other image (#87), one dir each so nothing collides with the base's `rootfs-*.ext4`:
222
+ * assets/images/<image>/rootfs-<version>.ext4, and rootfs.ext4 there the symlink to its current one.
223
+ */
224
+ images: join(home, "assets", "images"),
225
+ image: (image) => ({
226
+ dir: join(home, "assets", "images", image),
227
+ rootfs: join(home, "assets", "images", image, "rootfs.ext4"),
228
+ version: (version) => join(home, "assets", "images", image, `rootfs-${version}.ext4`)
229
+ }),
220
230
  machines: join(home, "machines"),
221
231
  snapshots: join(home, "snapshots"),
222
232
  /** Boxes and snapshots are filed by owner: machines/<owner>/<name>. The owner is part of a box's identity. */
@@ -227,6 +237,8 @@ function paths(home = kvboxHome()) {
227
237
  return {
228
238
  dir,
229
239
  meta: join(dir, "meta.json"),
240
+ /** The box's own environment variables (#87), merged over its owner's at boot. Mode 600: values in the clear. */
241
+ env: join(dir, "env.json"),
230
242
  /** The box's writable layer, stacked on the read-only base image inside the guest. */
231
243
  overlay: join(dir, "overlay.ext4"),
232
244
  /**
@@ -274,6 +286,8 @@ function paths(home = kvboxHome()) {
274
286
  meta: join(dir, "meta.json"),
275
287
  vmstate: join(dir, "vmstate"),
276
288
  mem: join(dir, "mem"),
289
+ /** The box's own environment variables when it was taken (#87); a restore starts with them. */
290
+ env: join(dir, "env.json"),
277
291
  /** Copy of the box's overlay at the moment of the snapshot; the base image is referenced by version in meta.json. */
278
292
  overlay: join(dir, "overlay.ext4")
279
293
  };
@@ -457,6 +471,21 @@ var DomainSchema = z2.object({
457
471
  records: z2.array(z2.object({ type: z2.enum(["A", "TXT", "CNAME"]), name: z2.string(), value: z2.string() })),
458
472
  createdAt: z2.string()
459
473
  });
474
+ var WakeHookSchema = z2.object({
475
+ id: z2.string(),
476
+ owner: z2.string(),
477
+ box: z2.string(),
478
+ url: z2.string(),
479
+ createdBy: z2.string().nullable(),
480
+ createdAt: z2.string(),
481
+ lastCalledAt: z2.string().nullable()
482
+ });
483
+ var CreatedWakeHookSchema = WakeHookSchema.extend({ secret: z2.string() });
484
+ var WakeHookCallSchema = z2.object({
485
+ box: z2.string(),
486
+ action: z2.enum(["wake", "resume", "none"]),
487
+ reason: z2.string().optional()
488
+ });
460
489
  var MachineSchema = z2.object({
461
490
  /** Host-unique short id (the tap is `kv-<id>`). Missing only on a box made before ids that has not restarted since. */
462
491
  id: z2.string(),
@@ -473,7 +502,9 @@ var MachineSchema = z2.object({
473
502
  diskUsedBytes: z2.number().int(),
474
503
  // what that sparse file really occupies on the host
475
504
  base: z2.string(),
476
- // base image version the box's overlay stacks on
505
+ // version of the image the box's overlay stacks on
506
+ /** The image (#87) when it is not the base one: `postgres`. `base` is then that image's version. */
507
+ image: z2.string().optional(),
477
508
  createdAt: z2.string(),
478
509
  source: z2.string(),
479
510
  // "base", "snapshot:<owner/name>" or "fork:<owner/name>" (#79)
@@ -498,7 +529,14 @@ var MachineSchema = z2.object({
498
529
  /** Volumes attached to the box (#52), in drive order; each is mounted at `mountPath` while the box runs. Absent: none. */
499
530
  volumes: z2.array(z2.object({ name: z2.string(), sizeGib: z2.number().int(), mountPath: z2.string() })).optional(),
500
531
  /** Boxes that may reach this one, each on one port (#98). Absent: none. */
501
- links: z2.array(BoxLinkSchema).optional()
532
+ links: z2.array(BoxLinkSchema).optional(),
533
+ /** How to reach what the box serves, its secrets masked (#87): `postgres://postgres:****@db.kvbox:5432/postgres`. */
534
+ url: z2.string().optional(),
535
+ /**
536
+ * Only in what `POST /machines` answers, for an image that declares one (#87): how to reach what it
537
+ * serves, e.g. `postgres://postgres:<password>@db.kvbox:5432/postgres`. Holds the box's variables.
538
+ */
539
+ connect: z2.string().optional()
502
540
  });
503
541
  var VolumeSchema = z2.object({
504
542
  /** The host's 6-hex volume id (#91): the ledger's key, so a name removed and made again is two volumes. */
@@ -535,6 +573,16 @@ var EnvVarSchema = z2.object({
535
573
  secret: z2.boolean(),
536
574
  updatedAt: z2.string()
537
575
  });
576
+ var BoxEnvSchema = z2.object({
577
+ box: z2.string(),
578
+ vars: z2.array(EnvVarSchema)
579
+ });
580
+ var BoxEnvChangeSchema = z2.object({
581
+ box: z2.string(),
582
+ name: z2.string(),
583
+ /** Whether the box is running now: the change waits for its next start. */
584
+ running: z2.boolean()
585
+ });
538
586
  var SetEnvRequest = z2.object({
539
587
  value: z2.string(),
540
588
  secret: z2.boolean().optional()
@@ -568,7 +616,11 @@ var CreateMachineRequest = z2.object({
568
616
  * Place the box on the host of this box (#98, `kvbox new --near`), so the two can be linked. Only the
569
617
  * control plane reads it; a host has one place to put a box.
570
618
  */
571
- near: z2.string().optional()
619
+ near: z2.string().optional(),
620
+ /** The image to boot (#87, `kvbox new --base postgres`). Absent: the base image. */
621
+ image: z2.string().optional(),
622
+ /** The box's own environment variables (#87, `kvbox new -e NAME=value`), over its owner's. */
623
+ env: z2.array(z2.object({ name: z2.string(), value: z2.string() })).optional()
572
624
  });
573
625
  var ForkMachineRequest = z2.object({
574
626
  name: z2.string().optional(),
@@ -603,7 +655,9 @@ var SnapshotSchema = z2.object({
603
655
  source: z2.string(),
604
656
  // the box it was taken from, as owner/name
605
657
  base: z2.string(),
606
- // base image version the overlay stacks on; a restore needs the same one
658
+ // version of the image the overlay stacks on; a restore needs the same one
659
+ /** As in MachineSchema: the image when it is not the base one (#87). */
660
+ image: z2.string().optional(),
607
661
  vcpu: z2.number().int(),
608
662
  memMib: z2.number().int(),
609
663
  sizeBytes: z2.number().int(),
@@ -630,7 +684,12 @@ var CapacitySchema = z2.object({
630
684
  reservedVcpu: z2.number().int(),
631
685
  running: z2.number().int(),
632
686
  /** Absent on a host from before volumes (#91): it cannot take one. */
633
- disk: DiskCapacitySchema.optional()
687
+ disk: DiskCapacitySchema.optional(),
688
+ /**
689
+ * The images a new box can be made from here (#87), with the version `new` uses; the base is `base`.
690
+ * Absent on a host from before images: it has only the base.
691
+ */
692
+ images: z2.array(z2.object({ name: z2.string(), version: z2.string() })).optional()
634
693
  });
635
694
  var RecoveryReportSchema = z2.object({
636
695
  at: z2.string(),
@@ -1156,6 +1215,16 @@ var ServerClient = class {
1156
1215
  removeLink(name, req) {
1157
1216
  return this.call("DELETE", `/machines/${encodeURIComponent(name)}/links`, MachineSchema, req);
1158
1217
  }
1218
+ /** Wake hooks (#101), the control plane's only: a URL and a secret that wake the box. */
1219
+ boxHooks(name) {
1220
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z3.array(WakeHookSchema));
1221
+ }
1222
+ createBoxHook(name) {
1223
+ return this.call("POST", `/machines/${encodeURIComponent(name)}/hooks`, CreatedWakeHookSchema);
1224
+ }
1225
+ removeBoxHook(name, id) {
1226
+ return this.call("DELETE", `/machines/${encodeURIComponent(name)}/hooks/${encodeURIComponent(id)}`, WakeHookSchema);
1227
+ }
1159
1228
  /** HTTPS names (#31), the control plane's only: the box's subdomain, claimed for its default port. */
1160
1229
  claimSubdomain(name, req) {
1161
1230
  return this.call("PUT", `/machines/${encodeURIComponent(name)}/subdomain`, SubdomainSchema, req);
@@ -1224,14 +1293,25 @@ var ServerClient = class {
1224
1293
  return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z3.undefined());
1225
1294
  }
1226
1295
  // ---- environment variables (#88), a control plane only: the caller's slug, or `--org`'s ----
1227
- listEnv() {
1228
- return this.call("GET", "/env", z3.array(EnvVarSchema));
1296
+ /** `org`: that org's list instead of `--org`'s (or the caller's own). */
1297
+ listEnv(org) {
1298
+ return this.call("GET", "/vars", z3.array(EnvVarSchema), void 0, org);
1229
1299
  }
1230
1300
  setEnv(name, req) {
1231
- return this.call("PUT", `/env/${encodeURIComponent(name)}`, EnvChangeSchema, req);
1301
+ return this.call("PUT", `/vars/${encodeURIComponent(name)}`, EnvChangeSchema, req);
1232
1302
  }
1233
1303
  removeEnv(name) {
1234
- return this.call("DELETE", `/env/${encodeURIComponent(name)}`, EnvChangeSchema);
1304
+ return this.call("DELETE", `/vars/${encodeURIComponent(name)}`, EnvChangeSchema);
1305
+ }
1306
+ // ---- a box's own variables (#87), kept on its host, over its owner's at its next start ----
1307
+ boxEnv(name) {
1308
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/env`, BoxEnvSchema);
1309
+ }
1310
+ setBoxEnv(name, variable, req) {
1311
+ return this.call("POST", `/machines/${encodeURIComponent(name)}/env/${encodeURIComponent(variable)}`, BoxEnvChangeSchema, req);
1312
+ }
1313
+ removeBoxEnv(name, variable) {
1314
+ return this.call("DELETE", `/machines/${encodeURIComponent(name)}/env/${encodeURIComponent(variable)}`, BoxEnvChangeSchema);
1235
1315
  }
1236
1316
  // ---- volumes (#52) ----
1237
1317
  listVolumes(opts = {}) {
@@ -1644,20 +1724,49 @@ async function pickVolume(client, keep, none) {
1644
1724
 
1645
1725
  // src/commands/vm/new.ts
1646
1726
  import { Command, Option } from "commander";
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) => {
1727
+
1728
+ // ../shared/src/env.ts
1729
+ var ENV_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
1730
+ var ENV_RESERVED = ["PATH", "HOME", "USER", "SHELL"];
1731
+ var ENV_MAX_VALUE_BYTES = 4096;
1732
+ function envNameProblem(name) {
1733
+ if (!ENV_NAME_RE.test(name)) return `${JSON.stringify(name)} is not a variable name: letters, digits and _, not starting with a digit`;
1734
+ if (ENV_RESERVED.includes(name)) return `${name} is the box's own and cannot be set`;
1735
+ if (name.startsWith("KVBOX_")) return `${name}: names starting with KVBOX_ are kept for kvbox`;
1736
+ return null;
1737
+ }
1738
+ function envValueProblem(value) {
1739
+ if (/[\n\r\0]/.test(value)) return "a value is one line: no line breaks (base64 a multi-line value such as a key file)";
1740
+ if (Buffer.byteLength(value, "utf8") > ENV_MAX_VALUE_BYTES) return `a value is at most ${ENV_MAX_VALUE_BYTES / 1024} KB`;
1741
+ return null;
1742
+ }
1743
+
1744
+ // src/commands/vm/new.ts
1745
+ var newCommand = new Command("new").description("boot a new box from an image (the base one, or e.g. postgres) 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("-b, --base <image>", "the image to boot: base (default) or one the host has, e.g. postgres").option("-e, --env <NAME=value>", "a variable of the box's own, over yours (repeatable; change later with kvbox env set --box)", collect, []).option("-f, --from <snapshot>", "start from a snapshot instead of an 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) => {
1648
1746
  const autoHibernateSec = opts.autoHibernate === void 0 ? void 0 : parseIdleTimeout(opts.autoHibernate);
1747
+ const env = parseEnvFlags(opts.env);
1649
1748
  const client = await clientFor(cmd.optsWithGlobals());
1650
1749
  try {
1651
- const what = opts.from !== void 0 ? `restoring ${name ?? "a new box"} from snapshot ${opts.from}\u2026` : `booting ${name ?? "a new box"}\u2026`;
1750
+ const what = opts.from !== void 0 ? `restoring ${name ?? "a new box"} from snapshot ${opts.from}\u2026` : `booting ${name ?? "a new box"}${opts.base !== void 0 && opts.base !== "base" ? ` from image ${opts.base}` : ""}\u2026`;
1652
1751
  const box = await spin(what, client.createMachine({
1653
1752
  ...name !== void 0 ? { name } : {},
1654
1753
  ...opts.size !== void 0 ? { size: opts.size } : {},
1655
1754
  ...opts.from !== void 0 ? { from: opts.from } : {},
1755
+ ...opts.base !== void 0 ? { image: opts.base } : {},
1756
+ ...env.length > 0 ? { env } : {},
1656
1757
  ...opts.near !== void 0 ? { near: opts.near } : {},
1657
1758
  ...autoHibernateSec !== void 0 ? { autoHibernateSec } : {},
1658
1759
  ...opts.force ? { force: true } : {}
1659
1760
  }));
1660
1761
  if (autoHibernateSec && !box.autoHibernateSec) warn(`box ${name ?? box.name}: its host runs a kvbox-server too old for auto-hibernate; it will not hibernate on its own`);
1762
+ if (opts.base !== void 0 && opts.base !== "base" && box.image === void 0) {
1763
+ warn(`box ${box.name}: its host runs a kvbox-server too old for images; it booted the base image, not ${opts.base}`);
1764
+ }
1765
+ if (env.length > 0) {
1766
+ const kept = await keptVars(client, displayName(box, me(client)), env.map((v) => v.name));
1767
+ if (kept === "too old") warn(`box ${box.name}: its host runs a kvbox-server too old for a box's own variables; it has none of the -e ones`);
1768
+ else if (kept !== true) warn(`box ${box.name}: could not check its -e variables (${kept}); kvbox env ls --box ${displayName(box, me(client))} shows them`);
1769
+ }
1661
1770
  if (opts.json) {
1662
1771
  json(box);
1663
1772
  return;
@@ -1669,10 +1778,24 @@ var newCommand = new Command("new").description("boot a new box from the base im
1669
1778
  if (opts.from !== void 0) info(` connect with: kvbox connect ${displayName(box, user)} (already up: everything that ran in the snapshot is running)`);
1670
1779
  else info(` connect with: kvbox connect ${displayName(box, user)} (SSH is up a couple of seconds after boot)`);
1671
1780
  if (box.autoHibernateSec) info(` it ${autoHibernateText(box.autoHibernateSec)}`);
1781
+ if (box.connect !== void 0) {
1782
+ info(` reach it at: ${box.connect}`);
1783
+ info(` from another box once linked: kvbox vm link <box> ${displayName(box, user)} --port <port>`);
1784
+ info(` its variables: kvbox env ls --box ${displayName(box, user)}`);
1785
+ }
1672
1786
  } finally {
1673
1787
  await client.close();
1674
1788
  }
1675
1789
  });
1790
+ async function keptVars(client, box, names) {
1791
+ try {
1792
+ const have = new Set((await client.boxEnv(box)).vars.map((v) => v.name));
1793
+ return names.every((n) => have.has(n)) ? true : "too old";
1794
+ } catch (err) {
1795
+ const message = err.message;
1796
+ return /no route:|too old/.test(message) ? "too old" : message;
1797
+ }
1798
+ }
1676
1799
  function displayName(box, user) {
1677
1800
  return user !== void 0 && slugOf(box.owner) !== user ? `${slugOf(box.owner)}/${box.name}` : box.name;
1678
1801
  }
@@ -1683,6 +1806,22 @@ function describe(box, user) {
1683
1806
  function autoHibernateText(sec) {
1684
1807
  return sec ? `hibernates after ${duration(sec)} without network traffic (kvbox connect wakes it)` : "never hibernates on its own";
1685
1808
  }
1809
+ function collect(value, previous) {
1810
+ return [...previous, value];
1811
+ }
1812
+ function parseEnvFlags(flags) {
1813
+ const out = /* @__PURE__ */ new Map();
1814
+ for (const flag of flags) {
1815
+ const eq = flag.indexOf("=");
1816
+ if (eq <= 0) throw new KvboxError(`-e ${flag}: expected NAME=value`);
1817
+ const name = flag.slice(0, eq);
1818
+ const value = flag.slice(eq + 1);
1819
+ const problem = envNameProblem(name) ?? envValueProblem(value);
1820
+ if (problem !== null) throw new KvboxError(`-e ${name}: ${problem}`);
1821
+ out.set(name, value);
1822
+ }
1823
+ return [...out].map(([name, value]) => ({ name, value }));
1824
+ }
1686
1825
  var UNIT_SEC = { m: 60, h: 3600, d: 86400 };
1687
1826
  function parseIdleTimeout(text2) {
1688
1827
  const t = text2.trim().toLowerCase();
@@ -1752,7 +1891,7 @@ function remoteCommand(cmdArgs, env) {
1752
1891
  }
1753
1892
  var TIMEOUT_EXIT = 124;
1754
1893
  var SSH_FAILED2 = 255;
1755
- function collect(value, previous) {
1894
+ function collect2(value, previous) {
1756
1895
  return [...previous ?? [], value];
1757
1896
  }
1758
1897
  function positiveSeconds(value) {
@@ -1780,7 +1919,7 @@ async function runSsh(ssh, opts) {
1780
1919
  }).finally(() => clearTimeout(timer));
1781
1920
  return { status: status2, chunks, timedOut };
1782
1921
  }
1783
- var execCommand = new Command3("exec").description("run a command in a box and exit with its status (kvbox exec <name> -- <cmd>)").argument("<name>", "box name").argument("<cmd...>", "command, passed to the box's shell as one string (pipes, &&, cd work)").option("-e, --env <KEY=VALUE>", "set an environment variable for the command (repeatable)", collect).option("--timeout <seconds>", "kill the command after N seconds and exit 124", positiveSeconds).option("--tty", "allocate a pseudo-terminal (for interactive tools like htop)").option("--json", 'capture output and print {"output": "...", "exit_code": N}').option("--direct", "on the box's host: ssh to the box's private ip, not through the public address or relay").action(async (name, cmdArgs, opts, cmd) => {
1922
+ var execCommand = new Command3("exec").description("run a command in a box and exit with its status (kvbox exec <name> -- <cmd>)").argument("<name>", "box name").argument("<cmd...>", "command, passed to the box's shell as one string (pipes, &&, cd work)").option("-e, --env <KEY=VALUE>", "set an environment variable for the command (repeatable)", collect2).option("--timeout <seconds>", "kill the command after N seconds and exit 124", positiveSeconds).option("--tty", "allocate a pseudo-terminal (for interactive tools like htop)").option("--json", 'capture output and print {"output": "...", "exit_code": N}').option("--direct", "on the box's host: ssh to the box's private ip, not through the public address or relay").action(async (name, cmdArgs, opts, cmd) => {
1784
1923
  const client = await clientFor(cmd.optsWithGlobals());
1785
1924
  let ep;
1786
1925
  let cert;
@@ -1897,7 +2036,8 @@ function lsRows(boxes, cloud) {
1897
2036
  address: addressOf(b),
1898
2037
  size: b.status === "unknown" ? "-" : `${shape(b.vcpu, b.memMib, b.diskBytes)} ${color.dim(`(${gbShort(b.diskUsedBytes)} used)`)}`,
1899
2038
  created: age(b.createdAt),
1900
- base: b.status === "unknown" || b.base === "" ? "-" : b.base
2039
+ // An image other than the base one (#87) is named: `postgres v0.1.0`.
2040
+ base: b.status === "unknown" || b.base === "" ? "-" : b.image !== void 0 ? `${b.image} ${b.base}` : b.base
1901
2041
  }));
1902
2042
  }
1903
2043
 
@@ -1971,13 +2111,14 @@ function getRows(box, sub, user) {
1971
2111
  rows2.push(["address", box.ssh?.host ?? (box.ip === "" ? "-" : box.ip)]);
1972
2112
  rows2.push(["ssh", box.ssh ? `ssh -p ${box.ssh.port} ${box.ssh.user}@${box.ssh.host}` : `kvbox connect ${displayName(box, user)}`]);
1973
2113
  }
2114
+ if (box.url !== void 0) rows2.push(["connect", `${box.url} ${color.dim("(password shown once, at new)")}`]);
1974
2115
  rows2.push(["url", sub ? [`${sub.url} ${color.dim(`(port ${sub.port})`)}`, ...sub.routes.map((r) => `${r.url} ${color.dim(`(port ${r.port})`)}`)].join(", ") : "-"]);
1975
2116
  const ports = rowsOf(box, user).map((r) => `${r.guestPort}/${r.proto} \u2192 ${reaches(r, true)}`);
1976
2117
  rows2.push(["ports", ports.length === 0 ? "-" : ports.join(", ")]);
1977
2118
  rows2.push(["volumes", box.volumes?.length ? box.volumes.map((v) => `${v.name} ${color.dim(`(${v.sizeGib} GB at ${v.mountPath})`)}`).join(", ") : "-"]);
1978
2119
  rows2.push(["auto-hibernate", box.autoHibernateSec ? `after ${duration(box.autoHibernateSec)} without network traffic` : "off"]);
1979
2120
  rows2.push(["source", box.source]);
1980
- rows2.push(["base", box.base]);
2121
+ rows2.push(["base", box.image === void 0 ? box.base : `${box.image} ${box.base}`]);
1981
2122
  rows2.push(["created", `${age(box.createdAt)} ${color.dim(`(${box.createdAt})`)}`]);
1982
2123
  return rows2;
1983
2124
  }
@@ -2325,9 +2466,93 @@ var setPortCommand = new Command16("set-port").description("point a box's HTTPS
2325
2466
  var proxyCommand = new Command17("proxy").description("publish box ports on the internet").addCommand(addCommand).addCommand(lsCommand2).addCommand(rmCommand).addCommand(claimCommand).addCommand(setPortCommand).addCommand(releaseCommand);
2326
2467
  for (const cmd of proxyCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
2327
2468
 
2469
+ // src/commands/vm/hook/index.ts
2470
+ import { Command as Command21 } from "commander";
2471
+
2472
+ // src/commands/vm/hook/create.ts
2473
+ import { Command as Command18 } from "commander";
2474
+
2475
+ // src/commands/vm/hook/shared.ts
2476
+ function requireCloud2(client) {
2477
+ if (client.target.kind !== "cloud") throw new KvboxError("wake hooks need the kvbox cloud: kvbox login (this host's own socket has none)");
2478
+ }
2479
+
2480
+ // src/commands/vm/hook/create.ts
2481
+ var createCommand = new Command18("create").description("make a URL that wakes the box when called (a GitHub webhook, cron, any automation)").argument("<box>", "box name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
2482
+ const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
2483
+ try {
2484
+ requireCloud2(client);
2485
+ const box = displayName(await findBox(client, name), me(client));
2486
+ const hook = await client.createBoxHook(box);
2487
+ if (opts.json) {
2488
+ json(hook);
2489
+ return;
2490
+ }
2491
+ info(`${color.green("\u2713")} hook ${hook.id} wakes box ${color.bold(box)}`);
2492
+ info(` url: ${hook.url}`);
2493
+ info(` secret: ${hook.secret} ${color.dim("(shown only now)")}`);
2494
+ info("");
2495
+ info(color.dim(" GitHub: repo Settings \u2192 Webhooks \u2192 Payload URL = the url, Content type = application/json,"));
2496
+ info(color.dim(" Secret = the secret, events: Workflow jobs."));
2497
+ info(color.dim(` anything else: curl -X POST -H "Authorization: Bearer <secret>" ${hook.url}`));
2498
+ info(color.dim(" A hibernated box wakes and a paused one resumes, at most once a minute; a stopped box stays stopped."));
2499
+ } finally {
2500
+ await client.close();
2501
+ }
2502
+ });
2503
+
2504
+ // src/commands/vm/hook/ls.ts
2505
+ import { Command as Command19 } from "commander";
2506
+ var lsCommand3 = new Command19("ls").alias("list").description("list a box's wake hooks").argument("<box>", "box name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
2507
+ const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
2508
+ try {
2509
+ requireCloud2(client);
2510
+ const box = displayName(await findBox(client, name), me(client));
2511
+ const hooks = await client.boxHooks(box);
2512
+ if (opts.json) {
2513
+ json(hooks);
2514
+ return;
2515
+ }
2516
+ if (hooks.length === 0) {
2517
+ info(`box ${box} has no wake hooks; make one with: kvbox vm hook create ${box}`);
2518
+ return;
2519
+ }
2520
+ table(hooks.map((h) => ({ id: h.id, url: h.url, "last called": h.lastCalledAt ? age(h.lastCalledAt) : color.dim("never"), by: h.createdBy ?? "-", created: age(h.createdAt) })));
2521
+ } finally {
2522
+ await client.close();
2523
+ }
2524
+ });
2525
+
2526
+ // src/commands/vm/hook/rm.ts
2527
+ import { Command as Command20 } from "commander";
2528
+ var rmCommand2 = new Command20("rm").alias("remove").description("remove a wake hook: its URL stops working").argument("<box>", "box name").argument("<id>", "the hook's id (kvbox vm hook ls <box>)").option("-y, --yes", "do not ask for confirmation").option("--json", "print the removed hook as JSON").action(async (name, id, opts, cmd) => {
2529
+ const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
2530
+ try {
2531
+ requireCloud2(client);
2532
+ const box = displayName(await findBox(client, name), me(client));
2533
+ if (!await confirm(`Remove hook ${id} of box ${box}? Whatever calls its URL stops waking the box.`, opts.yes ?? false)) {
2534
+ info("cancelled");
2535
+ process.exitCode = 1;
2536
+ return;
2537
+ }
2538
+ const hook = await client.removeBoxHook(box, id);
2539
+ if (opts.json) {
2540
+ json(hook);
2541
+ return;
2542
+ }
2543
+ info(`${color.green("\u2713")} hook ${hook.id} removed; its URL no longer wakes box ${color.bold(box)}`);
2544
+ } finally {
2545
+ await client.close();
2546
+ }
2547
+ });
2548
+
2549
+ // src/commands/vm/hook/index.ts
2550
+ var hookCommand = new Command21("hook").description("URLs that wake a box when called (GitHub webhooks, cron, any automation)").addCommand(createCommand).addCommand(lsCommand3).addCommand(rmCommand2);
2551
+ for (const cmd of hookCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
2552
+
2328
2553
  // src/commands/vm/rescale.ts
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) => {
2554
+ import { Command as Command22, Option as Option3 } from "commander";
2555
+ var rescaleCommand = new Command22("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) => {
2331
2556
  const req = {
2332
2557
  ...opts.size !== void 0 ? { size: opts.size } : {},
2333
2558
  ...opts.vcpu !== void 0 ? { vcpu: parseCount(opts.vcpu) } : {},
@@ -2372,8 +2597,8 @@ function parseGib(flag, text2) {
2372
2597
  }
2373
2598
 
2374
2599
  // src/commands/vm/resume.ts
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) => {
2600
+ import { Command as Command23 } from "commander";
2601
+ var resumeCommand = new Command23("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) => {
2377
2602
  const client = await clientFor(cmd.optsWithGlobals());
2378
2603
  try {
2379
2604
  const box = await spin(`resuming ${name}\u2026`, client.resumeMachine(name));
@@ -2385,8 +2610,8 @@ var resumeCommand = new Command19("resume").description("continue a box that is
2385
2610
  });
2386
2611
 
2387
2612
  // src/commands/vm/rm.ts
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) => {
2613
+ import { Command as Command24 } from "commander";
2614
+ var rmCommand3 = new Command24("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) => {
2390
2615
  const client = await clientFor(cmd.optsWithGlobals());
2391
2616
  try {
2392
2617
  const box = pickRef(await boxesFor(client, name), name, me(client));
@@ -2406,8 +2631,8 @@ var rmCommand2 = new Command20("rm").description("destroy a box (its disk is del
2406
2631
  });
2407
2632
 
2408
2633
  // src/commands/vm/set.ts
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) => {
2634
+ import { Command as Command25 } from "commander";
2635
+ var setCommand = new Command25("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) => {
2411
2636
  if (opts.autoHibernate === void 0) throw new KvboxError("nothing to change: give --auto-hibernate");
2412
2637
  const autoHibernateSec = parseIdleTimeout(opts.autoHibernate);
2413
2638
  const client = await clientFor(cmd.optsWithGlobals());
@@ -2426,8 +2651,8 @@ var setCommand = new Command21("set").description("change a box's settings, e.g.
2426
2651
  });
2427
2652
 
2428
2653
  // src/commands/vm/start.ts
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) => {
2654
+ import { Command as Command26 } from "commander";
2655
+ var startCommand = new Command26("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) => {
2431
2656
  const client = await clientFor(cmd.optsWithGlobals());
2432
2657
  try {
2433
2658
  const box = await spin(`booting ${name}\u2026`, client.startMachine(name));
@@ -2439,8 +2664,8 @@ var startCommand = new Command22("start").description("boot a stopped box again
2439
2664
  });
2440
2665
 
2441
2666
  // src/commands/vm/stop.ts
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) => {
2667
+ import { Command as Command27 } from "commander";
2668
+ var stopCommand = new Command27("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) => {
2444
2669
  const client = await clientFor(cmd.optsWithGlobals());
2445
2670
  try {
2446
2671
  const box = await spin(`shutting ${name} down\u2026`, client.stopMachine(name));
@@ -2452,8 +2677,8 @@ var stopCommand = new Command23("stop").description("shut a box down (its disk i
2452
2677
  });
2453
2678
 
2454
2679
  // src/commands/vm/top.ts
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) => {
2680
+ import { Command as Command28 } from "commander";
2681
+ var topCommand = new Command28("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) => {
2457
2682
  const client = await clientFor(cmd.optsWithGlobals());
2458
2683
  try {
2459
2684
  const running = (await client.listMachines({ all: opts.all })).filter((b) => b.status === "running");
@@ -2513,8 +2738,8 @@ function topRows(entries, cloud) {
2513
2738
  }
2514
2739
 
2515
2740
  // 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) => {
2741
+ import { Command as Command29 } from "commander";
2742
+ var unlinkCommand = new Command29("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
2743
  const port = parseLinkPort(opts.port);
2519
2744
  if (!await confirm(`Cut box ${from} off from box ${name} port ${port}? Its open connections close too.`, opts.yes ?? false)) {
2520
2745
  info("cancelled");
@@ -2535,8 +2760,8 @@ var unlinkCommand = new Command25("unlink").description("take a link away (kvbox
2535
2760
  });
2536
2761
 
2537
2762
  // src/commands/vm/update.ts
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) => {
2763
+ import { Command as Command30 } from "commander";
2764
+ var updateCommand = new Command30("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) => {
2540
2765
  const client = await clientFor(cmd.optsWithGlobals());
2541
2766
  try {
2542
2767
  const before = pickRef(await boxesFor(client, name), name, me(client));
@@ -2558,8 +2783,8 @@ var updateCommand = new Command26("update").description("move a box onto the cur
2558
2783
  });
2559
2784
 
2560
2785
  // src/commands/vm/usage.ts
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) => {
2786
+ import { Command as Command31 } from "commander";
2787
+ var usageCommand = new Command31("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) => {
2563
2788
  let since;
2564
2789
  if (opts.since !== void 0) {
2565
2790
  const t = Date.parse(opts.since);
@@ -2606,8 +2831,8 @@ function block(u) {
2606
2831
  }
2607
2832
 
2608
2833
  // src/commands/vm/wake.ts
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) => {
2834
+ import { Command as Command32 } from "commander";
2835
+ var wakeCommand = new Command32("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) => {
2611
2836
  const client = await clientFor(cmd.optsWithGlobals());
2612
2837
  try {
2613
2838
  const box = await spin(`waking ${name} (loading its memory from disk)\u2026`, client.wakeMachine(name));
@@ -2619,15 +2844,15 @@ var wakeCommand = new Command28("wake").description("continue a hibernated box w
2619
2844
  });
2620
2845
 
2621
2846
  // src/commands/vm/index.ts
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);
2623
- for (const cmd of vmCommand.commands) if (cmd !== proxyCommand) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
2624
- var vmAliases = [newCommand, lsCommand, getCommand, connectCommand, execCommand, stopCommand, startCommand, pauseCommand, resumeCommand, hibernateCommand, wakeCommand, rmCommand2, claimCommand];
2847
+ var vmCommand = new Command33("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(hookCommand).addCommand(linkCommand).addCommand(unlinkCommand).addCommand(linksCommand).addCommand(rmCommand3);
2848
+ for (const cmd of vmCommand.commands) if (cmd !== proxyCommand && cmd !== hookCommand) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
2849
+ var vmAliases = [newCommand, lsCommand, getCommand, connectCommand, execCommand, stopCommand, startCommand, pauseCommand, resumeCommand, hibernateCommand, wakeCommand, rmCommand3, claimCommand];
2625
2850
 
2626
2851
  // src/commands/server/index.ts
2627
- import { Command as Command37 } from "commander";
2852
+ import { Command as Command41 } from "commander";
2628
2853
 
2629
2854
  // src/commands/server/join.ts
2630
- import { Command as Command30 } from "commander";
2855
+ import { Command as Command34 } from "commander";
2631
2856
 
2632
2857
  // src/commands/server/daemon.ts
2633
2858
  import { spawn as spawn3 } from "child_process";
@@ -2681,7 +2906,7 @@ function runKvboxServer(args) {
2681
2906
  }
2682
2907
 
2683
2908
  // src/commands/server/join.ts
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) => {
2909
+ var joinCommand = new Command34("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) => {
2685
2910
  const args = ["join", url, "--token", opts.token];
2686
2911
  if (opts.advertise !== void 0) args.push("--advertise", opts.advertise);
2687
2912
  if (opts.name !== void 0) args.push("--name", opts.name);
@@ -2691,8 +2916,8 @@ var joinCommand = new Command30("join").description("put this machine behind a c
2691
2916
  });
2692
2917
 
2693
2918
  // src/commands/server/leave.ts
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 () => {
2919
+ import { Command as Command35 } from "commander";
2920
+ var leaveCommand = new Command35("leave").description("take this machine out from behind its control plane and restart its server").action(async () => {
2696
2921
  const p = paths();
2697
2922
  for (const line of (await runKvboxServer(["leave"])).split("\n")) info(line);
2698
2923
  if (await runningPid(p) === null) return;
@@ -2701,14 +2926,14 @@ var leaveCommand = new Command31("leave").description("take this machine out fro
2701
2926
  });
2702
2927
 
2703
2928
  // src/commands/server/relay.ts
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) => {
2929
+ import { Command as Command36 } from "commander";
2930
+ var relayCommand = new Command36("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) => {
2706
2931
  for (const line of (await runKvboxServer(["relay", joinString])).split("\n")) info(line);
2707
2932
  });
2708
2933
 
2709
2934
  // src/commands/server/start.ts
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) => {
2935
+ import { Command as Command37 } from "commander";
2936
+ var startCommand2 = new Command37("start").description("start the local kvbox-server in the background").action(async (_opts, cmd) => {
2712
2937
  const client = await clientFor({ ...cmd.optsWithGlobals(), local: true }, { autoStart: false });
2713
2938
  try {
2714
2939
  const health = await client.health();
@@ -2724,8 +2949,8 @@ var startCommand2 = new Command33("start").description("start the local kvbox-se
2724
2949
  });
2725
2950
 
2726
2951
  // src/commands/server/status.ts
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) => {
2952
+ import { Command as Command38 } from "commander";
2953
+ var statusCommand = new Command38("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) => {
2729
2954
  const client = await clientFor({ ...cmd.optsWithGlobals(), local: true });
2730
2955
  try {
2731
2956
  const health = await client.health();
@@ -2757,8 +2982,8 @@ var statusCommand = new Command34("status").description("show whether this machi
2757
2982
  });
2758
2983
 
2759
2984
  // src/commands/server/stop.ts
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 () => {
2985
+ import { Command as Command39 } from "commander";
2986
+ var stopCommand2 = new Command39("stop").description("stop the local server (running boxes are not affected)").action(async () => {
2762
2987
  const pid = await runningPid(paths());
2763
2988
  if (pid === null) throw new KvboxError("kvbox-server is not running");
2764
2989
  await stopLocalServer(pid);
@@ -2766,8 +2991,8 @@ var stopCommand2 = new Command35("stop").description("stop the local server (run
2766
2991
  });
2767
2992
 
2768
2993
  // src/commands/server/trust-ca.ts
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) => {
2994
+ import { Command as Command40 } from "commander";
2995
+ var trustCaCommand = new Command40("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) => {
2771
2996
  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");
2772
2997
  if (publicKey !== void 0 && opts.fromCloud) throw new KvboxError("either a public key or --from-cloud, not both");
2773
2998
  const client = await clientFor({ ...cmd.optsWithGlobals(), local: true });
@@ -2805,7 +3030,7 @@ function describeReport(report) {
2805
3030
  }
2806
3031
 
2807
3032
  // src/commands/server/index.ts
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);
3033
+ var serverCommand = new Command41("server").description("run or manage the kvbox server").addCommand(startCommand2).addCommand(statusCommand).addCommand(stopCommand2).addCommand(joinCommand).addCommand(leaveCommand).addCommand(relayCommand).addCommand(trustCaCommand);
2809
3034
 
2810
3035
  // src/commands/login.ts
2811
3036
  import { spawnSync as spawnSync3 } from "child_process";
@@ -2813,8 +3038,8 @@ import { mkdir as mkdir3, readFile as readFile5, writeFile as writeFile3 } from
2813
3038
  import { hostname as osHostname } from "os";
2814
3039
  import { createInterface as createInterface2 } from "readline/promises";
2815
3040
  import { Writable } from "stream";
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) => {
3041
+ import { Command as Command42 } from "commander";
3042
+ var loginCommand = new Command42("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) => {
2818
3043
  const url = normalizeUrl(urlArg ?? DEFAULT_CLOUD_URL);
2819
3044
  const creds = await readCredentials(opts);
2820
3045
  const session = await runLogin(url, creds, paths());
@@ -2894,8 +3119,8 @@ async function firstLine(stream) {
2894
3119
  }
2895
3120
 
2896
3121
  // src/commands/logout.ts
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 () => {
3122
+ import { Command as Command43 } from "commander";
3123
+ var logoutCommand = new Command43("logout").description("log out of the control plane; commands target this machine's kvbox-server again").action(async () => {
2899
3124
  const p = paths();
2900
3125
  const session = await readSession(p).catch(() => null);
2901
3126
  switch (await runLogout(p)) {
@@ -2932,8 +3157,8 @@ async function runLogout(p = paths()) {
2932
3157
  }
2933
3158
 
2934
3159
  // src/commands/whoami.ts
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) => {
3160
+ import { Command as Command44 } from "commander";
3161
+ var whoamiCommand = new Command44("whoami").description("show which account and control plane commands target (or local mode)").option("--json", "print as JSON").action(async (opts) => {
2937
3162
  const session = await readSession();
2938
3163
  if (opts.json) {
2939
3164
  json(session ? { user: session.user, url: session.url, sshCertExpires: session.sshCertExpires ?? null } : null);
@@ -2949,11 +3174,11 @@ function describeSession(session) {
2949
3174
  }
2950
3175
 
2951
3176
  // src/commands/snapshots/index.ts
2952
- import { Command as Command44 } from "commander";
3177
+ import { Command as Command48 } from "commander";
2953
3178
 
2954
3179
  // src/commands/snapshots/ls.ts
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) => {
3180
+ import { Command as Command45 } from "commander";
3181
+ var lsCommand4 = new Command45("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) => {
2957
3182
  const client = await clientFor(cmd.optsWithGlobals());
2958
3183
  try {
2959
3184
  const cloud = client.target.kind === "cloud";
@@ -2984,8 +3209,8 @@ var lsCommand3 = new Command41("ls").description("list snapshots (yours and your
2984
3209
  });
2985
3210
 
2986
3211
  // src/commands/snapshots/new.ts
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) => {
3212
+ import { Command as Command46 } from "commander";
3213
+ var newCommand2 = new Command46("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) => {
2989
3214
  const client = await clientFor(cmd.optsWithGlobals());
2990
3215
  try {
2991
3216
  const req = { box, name, ...opts.replace ? { replace: true } : {} };
@@ -2998,8 +3223,8 @@ var newCommand2 = new Command42("new").description("freeze a running box (memory
2998
3223
  });
2999
3224
 
3000
3225
  // src/commands/snapshots/rm.ts
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) => {
3226
+ import { Command as Command47 } from "commander";
3227
+ var rmCommand4 = new Command47("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) => {
3003
3228
  if (!await confirm(`Delete snapshot ${name}?`, opts.yes ?? false)) {
3004
3229
  info("cancelled");
3005
3230
  process.exitCode = 1;
@@ -3015,14 +3240,14 @@ var rmCommand3 = new Command43("rm").description("delete a snapshot (boxes made
3015
3240
  });
3016
3241
 
3017
3242
  // src/commands/snapshots/index.ts
3018
- var snapshotsCommand = new Command44("snapshots").aliases(["snapshot", "snap"]).description("freeze running boxes into snapshots and manage them").addCommand(newCommand2).addCommand(lsCommand3).addCommand(rmCommand3);
3243
+ var snapshotsCommand = new Command48("snapshots").aliases(["snapshot", "snap"]).description("freeze running boxes into snapshots and manage them").addCommand(newCommand2).addCommand(lsCommand4).addCommand(rmCommand4);
3019
3244
  for (const cmd of snapshotsCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
3020
3245
 
3021
3246
  // src/commands/org/index.ts
3022
- import { Command as Command50 } from "commander";
3247
+ import { Command as Command54 } from "commander";
3023
3248
 
3024
3249
  // src/commands/org/ls.ts
3025
- import { Command as Command45 } from "commander";
3250
+ import { Command as Command49 } from "commander";
3026
3251
 
3027
3252
  // src/commands/org/context.ts
3028
3253
  var NOT_LOGGED_IN = "orgs live on the control plane: kvbox login first";
@@ -3042,7 +3267,7 @@ function orgFor(opts, target) {
3042
3267
  }
3043
3268
 
3044
3269
  // src/commands/org/ls.ts
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) => {
3270
+ var lsCommand5 = new Command49("ls").description("list the orgs you belong to and your role in each").option("--json", "print as JSON").action(async (opts, cmd) => {
3046
3271
  const client = await cloudClientFor(cmd.optsWithGlobals());
3047
3272
  try {
3048
3273
  const orgs = await client.listOrgs();
@@ -3064,8 +3289,8 @@ function orgRows(orgs) {
3064
3289
  }
3065
3290
 
3066
3291
  // src/commands/org/members.ts
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) => {
3292
+ import { Command as Command50, Option as Option4 } from "commander";
3293
+ var lsCommand6 = new Command50("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) => {
3069
3294
  const client = await cloudClientFor(cmd.optsWithGlobals());
3070
3295
  try {
3071
3296
  const org = await client.getOrg(orgFor(opts, client.target));
@@ -3079,7 +3304,7 @@ var lsCommand5 = new Command46("ls").description("list an org's members and thei
3079
3304
  await client.close();
3080
3305
  }
3081
3306
  });
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) => {
3307
+ var addCommand2 = new Command50("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) => {
3083
3308
  const client = await cloudClientFor(cmd.optsWithGlobals());
3084
3309
  try {
3085
3310
  const slug = orgFor(opts, client.target);
@@ -3089,7 +3314,7 @@ var addCommand2 = new Command46("add").description("add a user to an org (admins
3089
3314
  await client.close();
3090
3315
  }
3091
3316
  });
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) => {
3317
+ var rmCommand5 = new Command50("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) => {
3093
3318
  const client = await cloudClientFor(cmd.optsWithGlobals());
3094
3319
  try {
3095
3320
  const slug = orgFor(opts, client.target);
@@ -3105,11 +3330,11 @@ var rmCommand4 = new Command46("rm").description("remove a member (or leave: rem
3105
3330
  await client.close();
3106
3331
  }
3107
3332
  });
3108
- var membersCommand = new Command46("members").description("who is in an org and what they may do").addCommand(lsCommand5).addCommand(addCommand2).addCommand(rmCommand4);
3333
+ var membersCommand = new Command50("members").description("who is in an org and what they may do").addCommand(lsCommand6).addCommand(addCommand2).addCommand(rmCommand5);
3109
3334
 
3110
3335
  // src/commands/org/new.ts
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) => {
3336
+ import { Command as Command51 } from "commander";
3337
+ var newCommand3 = new Command51("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) => {
3113
3338
  const client = await cloudClientFor(cmd.optsWithGlobals());
3114
3339
  try {
3115
3340
  const org = await client.createOrg({ slug, name: opts.name ?? slug });
@@ -3125,8 +3350,8 @@ var newCommand3 = new Command47("new").description("create an org; you become it
3125
3350
  });
3126
3351
 
3127
3352
  // src/commands/org/rm.ts
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) => {
3353
+ import { Command as Command52 } from "commander";
3354
+ var rmCommand6 = new Command52("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) => {
3130
3355
  if (!await confirm(`Delete org ${slug}? Its members lose access; its slug stays taken.`, opts.yes ?? false)) {
3131
3356
  info("cancelled");
3132
3357
  process.exitCode = 1;
@@ -3142,8 +3367,8 @@ var rmCommand5 = new Command48("rm").description("delete an org (owners only; re
3142
3367
  });
3143
3368
 
3144
3369
  // src/commands/org/role.ts
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) => {
3370
+ import { Argument, Command as Command53 } from "commander";
3371
+ var roleCommand = new Command53("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) => {
3147
3372
  const client = await cloudClientFor(cmd.optsWithGlobals());
3148
3373
  try {
3149
3374
  const slug = orgFor(opts, client.target);
@@ -3155,10 +3380,10 @@ var roleCommand = new Command49("role").description("change a member's role (own
3155
3380
  });
3156
3381
 
3157
3382
  // src/commands/org/index.ts
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);
3383
+ var orgCommand = new Command54("org").description("orgs: shared slugs that own boxes, with owners, admins and members").addCommand(lsCommand5).addCommand(newCommand3).addCommand(membersCommand).addCommand(roleCommand).addCommand(rmCommand6);
3159
3384
 
3160
3385
  // src/commands/usage.ts
3161
- import { Command as Command51 } from "commander";
3386
+ import { Command as Command55 } from "commander";
3162
3387
 
3163
3388
  // ../shared/src/usage.ts
3164
3389
  import { z as z4 } from "zod";
@@ -3168,7 +3393,8 @@ var PricingSchema = z4.object({
3168
3393
  ramGibHour: z4.number().nonnegative(),
3169
3394
  diskGibHour: z4.number().nonnegative(),
3170
3395
  volumeHour: z4.number().nonnegative().default(0),
3171
- volumeGibHour: z4.number().nonnegative().default(0)
3396
+ volumeGibHour: z4.number().nonnegative().default(0),
3397
+ diskIncludedGib: z4.number().int().nonnegative().default(0)
3172
3398
  });
3173
3399
  var round = (n, places) => Math.round(n * 10 ** places) / 10 ** places;
3174
3400
  function costOf(t, pricing) {
@@ -3195,7 +3421,7 @@ function sumUsage(items, pricing) {
3195
3421
  }
3196
3422
 
3197
3423
  // src/commands/usage.ts
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) => {
3424
+ var usageCommand2 = new Command55("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) => {
3199
3425
  for (const [name, value] of [
3200
3426
  ["since", opts.since],
3201
3427
  ["until", opts.until]
@@ -3341,8 +3567,8 @@ function userRows(r) {
3341
3567
  }
3342
3568
 
3343
3569
  // src/commands/credit.ts
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) => {
3570
+ import { Command as Command56 } from "commander";
3571
+ var creditCommand = new Command56("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) => {
3346
3572
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
3347
3573
  try {
3348
3574
  if (client.target.kind === "local") throw new KvboxError("credit lives on the control plane: kvbox login first");
@@ -3372,7 +3598,7 @@ function creditRow(b, me2) {
3372
3598
  // src/commands/deploy/index.ts
3373
3599
  import { readFile as readFile7 } from "fs/promises";
3374
3600
  import { basename, resolve as resolve2 } from "path";
3375
- import { Command as Command53, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
3601
+ import { Command as Command57, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
3376
3602
 
3377
3603
  // src/commands/deploy/config.ts
3378
3604
  import { readFile as readFile6, writeFile as writeFile4 } from "fs/promises";
@@ -3700,7 +3926,7 @@ async function ship(ep, dir, remote, exclude = []) {
3700
3926
  var shipping = { ship, measure, waitForSsh };
3701
3927
 
3702
3928
  // src/commands/deploy/index.ts
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) => {
3929
+ var deployCommand = new Command57("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) => {
3704
3930
  const dir = resolve2(dirArg ?? ".");
3705
3931
  const pkg = await readPackageJson(dir);
3706
3932
  const saved = await readConfig(dir);
@@ -3897,15 +4123,15 @@ the app is on box ${ref} but has no address yet: pick another with kvbox deploy
3897
4123
  }
3898
4124
 
3899
4125
  // src/commands/volume/index.ts
3900
- import { Command as Command59 } from "commander";
4126
+ import { Command as Command63 } from "commander";
3901
4127
 
3902
4128
  // src/commands/volume/attach.ts
3903
- import { Command as Command54 } from "commander";
4129
+ import { Command as Command58 } from "commander";
3904
4130
  function describeMount(machine, volume, box) {
3905
4131
  const path = machine.volumes?.find((v) => volume === v.name || volume.endsWith(`/${v.name}`))?.mountPath ?? volumeMountPath(volume.slice(volume.lastIndexOf("/") + 1));
3906
4132
  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`;
3907
4133
  }
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) => {
4134
+ var attachCommand = new Command58("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) => {
3909
4135
  if (volumeArg === void 0 || boxArg === void 0) askOrUsage("give the volume and the box: kvbox volume attach <volume> <box>");
3910
4136
  const client = await clientFor(cmd.optsWithGlobals());
3911
4137
  try {
@@ -3924,7 +4150,7 @@ var attachCommand = new Command54("attach").description("attach a volume to a bo
3924
4150
  });
3925
4151
 
3926
4152
  // src/commands/volume/create.ts
3927
- import { Command as Command55 } from "commander";
4153
+ import { Command as Command59 } from "commander";
3928
4154
  function parseGib2(text2) {
3929
4155
  const mib = parseMib(text2);
3930
4156
  if (mib === void 0 || mib % 1024 !== 0) throw new KvboxError(`--size ${text2}: write whole GB, like 50 or 50GB`);
@@ -3940,7 +4166,7 @@ function sizeProblem(answer) {
3940
4166
  return err instanceof KvboxError ? err.message.replace(/^--size \S+: /, "") : String(err);
3941
4167
  }
3942
4168
  }
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) => {
4169
+ var createCommand2 = new Command59("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) => {
3944
4170
  const ask = interactive();
3945
4171
  if (nameArg === void 0 || opts.size === void 0) askOrUsage("give the name and the size: kvbox volume create <name> --size <gb> --box <box>");
3946
4172
  const name = nameArg ?? await text("Volume name", { validate: (a) => VOLUME_NAME_RE.test(a) ? void 0 : VOLUME_NAME_RULE });
@@ -3973,8 +4199,8 @@ var createCommand = new Command55("create").alias("new").description("create a v
3973
4199
  });
3974
4200
 
3975
4201
  // src/commands/volume/detach.ts
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) => {
4202
+ import { Command as Command60 } from "commander";
4203
+ var detachCommand = new Command60("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) => {
3978
4204
  if (volumeArg === void 0) askOrUsage("give the volume: kvbox volume detach <volume> [box]");
3979
4205
  const client = await clientFor(cmd.optsWithGlobals());
3980
4206
  try {
@@ -3999,8 +4225,8 @@ var detachCommand = new Command56("detach").description("detach a volume from a
3999
4225
  });
4000
4226
 
4001
4227
  // src/commands/volume/ls.ts
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) => {
4228
+ import { Command as Command61 } from "commander";
4229
+ var lsCommand7 = new Command61("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) => {
4004
4230
  const client = await clientFor(cmd.optsWithGlobals());
4005
4231
  try {
4006
4232
  const cloud = client.target.kind === "cloud";
@@ -4031,8 +4257,8 @@ var lsCommand6 = new Command57("ls").alias("list").description("list volumes: si
4031
4257
  });
4032
4258
 
4033
4259
  // src/commands/volume/rm.ts
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) => {
4260
+ import { Command as Command62 } from "commander";
4261
+ var rmCommand7 = new Command62("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) => {
4036
4262
  if (!await confirm(`Delete volume ${name} and everything on it?`, opts.yes ?? false)) {
4037
4263
  info("cancelled");
4038
4264
  process.exitCode = 1;
@@ -4048,17 +4274,17 @@ var rmCommand6 = new Command58("rm").alias("remove").description("delete a volum
4048
4274
  });
4049
4275
 
4050
4276
  // src/commands/volume/index.ts
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);
4277
+ var volumeCommand = new Command63("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(createCommand2).addCommand(lsCommand7).addCommand(attachCommand).addCommand(detachCommand).addCommand(rmCommand7);
4052
4278
  for (const cmd of volumeCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
4053
4279
 
4054
4280
  // src/commands/env/index.ts
4055
- import { Command as Command63 } from "commander";
4281
+ import { Command as Command67 } from "commander";
4056
4282
 
4057
4283
  // src/commands/env/ls.ts
4058
- import { Command as Command60 } from "commander";
4284
+ import { Command as Command64 } from "commander";
4059
4285
 
4060
4286
  // src/commands/env/shared.ts
4061
- function requireCloud2(client) {
4287
+ function requireCloud3(client) {
4062
4288
  if (client.target.kind === "local") throw new KvboxError("kvbox env needs kvbox.sh: kvbox login first");
4063
4289
  return client.target.org ?? client.target.user ?? "you";
4064
4290
  }
@@ -4066,12 +4292,45 @@ function reach(boxes, verb) {
4066
4292
  if (boxes === 0) return verb === "get" ? "no boxes yet, every new one gets it" : "no boxes yet";
4067
4293
  return boxes === 1 ? `1 box ${verb}s it when it next starts` : `${boxes} boxes ${verb} it when they next start`;
4068
4294
  }
4295
+ async function findBox2(client, name) {
4296
+ const box = pickRef(await boxesFor(client, name), name, me(client));
4297
+ if (!box) throw new KvboxError(`box ${name}: not found (kvbox ls)`);
4298
+ return { box, ref: displayName(box, me(client)) };
4299
+ }
4300
+ function boxReach(running, verb) {
4301
+ return running ? `it ${verb} it when it next starts (kvbox stop, kvbox start)` : `it ${verb} it when it starts`;
4302
+ }
4303
+ function firstBootHint(box, name) {
4304
+ if (box.image === "postgres" && /^POSTGRES_(USER|PASSWORD|DB)$/.test(name)) {
4305
+ return `${name} is read once, when the box first boots: the database keeps the user, password and database it was made with (change them with psql in the box)`;
4306
+ }
4307
+ return void 0;
4308
+ }
4069
4309
 
4070
4310
  // src/commands/env/ls.ts
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) => {
4311
+ var lsCommand8 = new Command64("ls").alias("list").description("list the variables (a secret shows as (sealed))").option("--box <box>", "what this box gets: its own variables and the ones it inherits").option("--json", "print as JSON").action(async (opts, cmd) => {
4072
4312
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
4073
4313
  try {
4074
- const owner = requireCloud2(client);
4314
+ if (opts.box !== void 0) {
4315
+ const { box, ref } = await findBox2(client, opts.box);
4316
+ const own = await client.boxEnv(ref);
4317
+ const slug = slugOf(box.owner);
4318
+ const theirs = client.target.kind === "cloud" ? await client.listEnv(slug === me(client) ? void 0 : slug) : [];
4319
+ const mine = new Set(own.vars.map((v) => v.name));
4320
+ const inherited = theirs.filter((v) => !mine.has(v.name));
4321
+ if (opts.json) {
4322
+ json({ box: own.box, vars: own.vars, inherited });
4323
+ return;
4324
+ }
4325
+ if (own.vars.length === 0 && inherited.length === 0) {
4326
+ info(`box ${ref} gets no variables; set one with: kvbox env set NAME value --box ${ref}`);
4327
+ return;
4328
+ }
4329
+ const row = (v, from) => ({ name: v.name, value: v.secret ? color.dim("(sealed)") : v.value, from, updated: age(v.updatedAt) });
4330
+ table([...own.vars.map((v) => row(v, "box")), ...inherited.map((v) => row(v, color.dim(slug)))]);
4331
+ return;
4332
+ }
4333
+ const owner = requireCloud3(client);
4075
4334
  const vars = await client.listEnv();
4076
4335
  if (opts.json) {
4077
4336
  json(vars);
@@ -4088,11 +4347,12 @@ var lsCommand7 = new Command60("ls").alias("list").description("list the variabl
4088
4347
  });
4089
4348
 
4090
4349
  // src/commands/env/rm.ts
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) => {
4350
+ import { Command as Command65 } from "commander";
4351
+ var rmCommand8 = new Command65("rm").alias("remove").description("remove variables; boxes lose them when they next start").argument("<names...>", "variable names").option("-y, --yes", "do not ask for confirmation").option("--box <box>", "remove this box's own variables (yours, or the org's, of the same name come back)").option("--json", "print as JSON").action(async (names, opts, cmd) => {
4093
4352
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
4094
4353
  try {
4095
- const owner = requireCloud2(client);
4354
+ const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
4355
+ const owner = target === void 0 ? requireCloud3(client) : `box ${target.ref}`;
4096
4356
  if (!await confirm(`Remove ${names.join(", ")} from ${owner}'s variables?`, opts.yes ?? false)) {
4097
4357
  info("cancelled");
4098
4358
  process.exitCode = 1;
@@ -4102,6 +4362,12 @@ var rmCommand7 = new Command61("rm").alias("remove").description("remove variabl
4102
4362
  const failed = [];
4103
4363
  for (const name of names) {
4104
4364
  try {
4365
+ if (target !== void 0) {
4366
+ const c2 = await spin(`removing ${name}\u2026`, client.removeBoxEnv(target.ref, name));
4367
+ changes.push(c2);
4368
+ if (!opts.json) info(`${color.green("\u2713")} removed ${c2.name} from ${owner}: ${boxReach(c2.running, "loses")}`);
4369
+ continue;
4370
+ }
4105
4371
  const c = await spin(`removing ${name}\u2026`, client.removeEnv(name));
4106
4372
  changes.push(c);
4107
4373
  if (!opts.json) info(`${color.green("\u2713")} removed ${c.name} from ${owner}: ${reach(c.boxes, "lose")}`);
@@ -4119,29 +4385,12 @@ var rmCommand7 = new Command61("rm").alias("remove").description("remove variabl
4119
4385
  });
4120
4386
 
4121
4387
  // src/commands/env/set.ts
4122
- import { Command as Command62 } from "commander";
4123
-
4124
- // ../shared/src/env.ts
4125
- var ENV_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
4126
- var ENV_RESERVED = ["PATH", "HOME", "USER", "SHELL"];
4127
- var ENV_MAX_VALUE_BYTES = 4096;
4128
- function envNameProblem(name) {
4129
- if (!ENV_NAME_RE.test(name)) return `${JSON.stringify(name)} is not a variable name: letters, digits and _, not starting with a digit`;
4130
- if (ENV_RESERVED.includes(name)) return `${name} is the box's own and cannot be set`;
4131
- if (name.startsWith("KVBOX_")) return `${name}: names starting with KVBOX_ are kept for kvbox`;
4132
- return null;
4133
- }
4134
- function envValueProblem(value) {
4135
- if (/[\n\r\0]/.test(value)) return "a value is one line: no line breaks (base64 a multi-line value such as a key file)";
4136
- if (Buffer.byteLength(value, "utf8") > ENV_MAX_VALUE_BYTES) return `a value is at most ${ENV_MAX_VALUE_BYTES / 1024} KB`;
4137
- return null;
4138
- }
4139
-
4140
- // src/commands/env/set.ts
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) => {
4388
+ import { Command as Command66 } from "commander";
4389
+ var setCommand2 = new Command66("set").description("add or change a variable; boxes get it when they next start").argument("[name]", "variable name, e.g. DATABASE_URL (asked for when left out)").argument("[value]", "its value (asked for when left out; hidden with --secret)").option("--secret", "write-only: the value is never shown again, by any command").option("--box <box>", "this box's own variable, over yours (or the org's) of the same name").option("--json", "print as JSON").action(async (nameArg, valueArg, opts, cmd) => {
4142
4390
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
4143
4391
  try {
4144
- const owner = requireCloud2(client);
4392
+ const owner = opts.box === void 0 ? requireCloud3(client) : void 0;
4393
+ const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
4145
4394
  const ask = interactive();
4146
4395
  if ((nameArg === void 0 || valueArg === void 0) && !ask) throw new KvboxError("give the name and the value: kvbox env set NAME VALUE (or run it in a terminal to be asked)");
4147
4396
  const name = nameArg ?? await text("Variable name", { validate: (a) => envNameProblem(a) ?? void 0 });
@@ -4150,12 +4399,23 @@ var setCommand2 = new Command62("set").description("add or change a variable; bo
4150
4399
  const value = valueArg ?? (opts.secret ? await hiddenText(`Value for ${name}`) : await text(`Value for ${name}`, { trim: false }));
4151
4400
  const valueProblem = envValueProblem(value);
4152
4401
  if (valueProblem !== null) throw new KvboxError(valueProblem);
4402
+ const what = opts.secret ? `${name} (secret)` : name;
4403
+ if (target !== void 0) {
4404
+ const change2 = await spin(`setting ${name}\u2026`, client.setBoxEnv(target.ref, name, { value, secret: opts.secret ?? false }));
4405
+ if (opts.json) {
4406
+ json(change2);
4407
+ return;
4408
+ }
4409
+ info(`${color.green("\u2713")} set ${what} on box ${color.bold(target.ref)}: ${boxReach(change2.running, "gets")}`);
4410
+ const hint = firstBootHint(target.box, name);
4411
+ if (hint !== void 0) warn(hint);
4412
+ return;
4413
+ }
4153
4414
  const change = await spin(`setting ${name}\u2026`, client.setEnv(name, { value, secret: opts.secret ?? false }));
4154
4415
  if (opts.json) {
4155
4416
  json(change);
4156
4417
  return;
4157
4418
  }
4158
- const what = opts.secret ? `${name} (secret)` : name;
4159
4419
  info(`${color.green("\u2713")} set ${what} for ${owner}: ${reach(change.boxes, "get")}`);
4160
4420
  } finally {
4161
4421
  await client.close();
@@ -4163,17 +4423,17 @@ var setCommand2 = new Command62("set").description("add or change a variable; bo
4163
4423
  });
4164
4424
 
4165
4425
  // src/commands/env/index.ts
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);
4426
+ var envCommand = new Command67("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand8, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand8);
4167
4427
  for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
4168
4428
 
4169
4429
  // src/commands/domain/index.ts
4170
- import { Command as Command67 } from "commander";
4430
+ import { Command as Command71 } from "commander";
4171
4431
 
4172
4432
  // src/commands/domain/add.ts
4173
- import { Command as Command64 } from "commander";
4433
+ import { Command as Command68 } from "commander";
4174
4434
 
4175
4435
  // src/commands/domain/shared.ts
4176
- function requireCloud3(client) {
4436
+ function requireCloud4(client) {
4177
4437
  if (client.target.kind !== "cloud") throw new KvboxError("custom domains need the kvbox cloud: kvbox login (this host's own socket has none)");
4178
4438
  }
4179
4439
  var boxOf2 = (d, user) => user !== void 0 && d.owner !== user ? `${d.owner}/${d.box}` : d.box;
@@ -4190,12 +4450,12 @@ function hostIn(name, zone) {
4190
4450
  }
4191
4451
 
4192
4452
  // src/commands/domain/add.ts
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) => {
4453
+ var addCommand3 = new Command68("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) => {
4194
4454
  const domain = assertDomain(domainArg.trim().toLowerCase());
4195
4455
  const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
4196
4456
  const client = await clientFor(cmd.optsWithGlobals());
4197
4457
  try {
4198
- requireCloud3(client);
4458
+ requireCloud4(client);
4199
4459
  const user = me(client);
4200
4460
  const box = displayName(await findBox(client, name), user);
4201
4461
  const d = await spin(`adding ${domain}\u2026`, client.addDomain(box, { domain, ...port !== void 0 ? { port } : {} }));
@@ -4226,11 +4486,11 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
4226
4486
  });
4227
4487
 
4228
4488
  // src/commands/domain/ls.ts
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) => {
4489
+ import { Command as Command69 } from "commander";
4490
+ var lsCommand9 = new Command69("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
4231
4491
  const client = await clientFor(cmd.optsWithGlobals());
4232
4492
  try {
4233
- requireCloud3(client);
4493
+ requireCloud4(client);
4234
4494
  const user = me(client);
4235
4495
  const domains = await client.listDomains();
4236
4496
  if (opts.json) {
@@ -4256,12 +4516,12 @@ var lsCommand8 = new Command65("ls").alias("list").description("list your custom
4256
4516
  });
4257
4517
 
4258
4518
  // src/commands/domain/rm.ts
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) => {
4519
+ import { Command as Command70 } from "commander";
4520
+ var rmCommand9 = new Command70("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) => {
4261
4521
  const domain = domainArg.trim().toLowerCase();
4262
4522
  const client = await clientFor(cmd.optsWithGlobals());
4263
4523
  try {
4264
- requireCloud3(client);
4524
+ requireCloud4(client);
4265
4525
  const found = (await client.listDomains()).find((d) => d.domain === domain);
4266
4526
  if (!found) throw new KvboxError(`domain ${domain}: not found (kvbox domain ls)`);
4267
4527
  const box = boxOf2(found, me(client));
@@ -4278,12 +4538,12 @@ var rmCommand8 = new Command66("rm").alias("remove").description("stop serving a
4278
4538
  });
4279
4539
 
4280
4540
  // src/commands/domain/index.ts
4281
- var domainCommand = new Command67("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand3).addCommand(lsCommand8).addCommand(rmCommand8);
4541
+ var domainCommand = new Command71("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand3).addCommand(lsCommand9).addCommand(rmCommand9);
4282
4542
  for (const cmd of domainCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
4283
4543
 
4284
4544
  // src/program.ts
4285
4545
  function buildProgram() {
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();
4546
+ const program = new Command72("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();
4287
4547
  program.addCommand(vmCommand);
4288
4548
  program.addCommand(snapshotsCommand);
4289
4549
  program.addCommand(volumeCommand);