@kvbox/cli 0.6.18 → 0.6.20

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
@@ -155,7 +155,7 @@ async function spin(message, work, opts = {}) {
155
155
  }
156
156
 
157
157
  // src/program.ts
158
- import { Command as Command140 } from "commander";
158
+ import { Command as Command142 } from "commander";
159
159
 
160
160
  // ../shared/src/version.ts
161
161
  import { createRequire } from "module";
@@ -170,10 +170,10 @@ function versionOf(srcFileUrl, injected) {
170
170
  }
171
171
 
172
172
  // src/version.ts
173
- var VERSION = versionOf(import.meta.url, true ? "0.6.18" : void 0);
173
+ var VERSION = versionOf(import.meta.url, true ? "0.6.20" : void 0);
174
174
 
175
175
  // src/commands/vm/index.ts
176
- import { Command as Command42 } from "commander";
176
+ import { Command as Command44 } from "commander";
177
177
 
178
178
  // src/commands/vm/connect.ts
179
179
  import { spawnSync as spawnSync3 } from "child_process";
@@ -464,8 +464,8 @@ function parseMib(text2) {
464
464
  if (!m) return void 0;
465
465
  const n2 = Number(m[1]);
466
466
  const unit = (m[2] ?? "g").toLowerCase();
467
- const mib = unit.startsWith("m") ? n2 : n2 * 1024;
468
- return Number.isInteger(mib) && mib > 0 ? mib : void 0;
467
+ const mib2 = unit.startsWith("m") ? n2 : n2 * 1024;
468
+ return Number.isInteger(mib2) && mib2 > 0 ? mib2 : void 0;
469
469
  }
470
470
 
471
471
  // ../shared/src/api.ts
@@ -545,6 +545,7 @@ var WakeHookSchema = z2.object({
545
545
  createdAt: z2.string(),
546
546
  lastCalledAt: z2.string().nullable()
547
547
  });
548
+ var WakeHookListSchema = z2.array(WakeHookSchema);
548
549
  var CreatedWakeHookSchema = WakeHookSchema.extend({ secret: z2.string() });
549
550
  var WakeHookCallSchema = z2.object({
550
551
  box: z2.string(),
@@ -753,6 +754,13 @@ var MachineSchema = z2.object({
753
754
  */
754
755
  latestBase: z2.string().optional(),
755
756
  createdAt: z2.string(),
757
+ /**
758
+ * When the guest last got its variables by a fresh start (#155): the host's clock at a cold boot (`new`, `start`
759
+ * and the restarts behind rescale, update, volume attach), or at a warm `new --from`/fork, which hands the copy
760
+ * its variables of that moment. A wake or resume keeps it. A variable changed after it waits for the next start.
761
+ * Absent: a host before it, or a box not booted since.
762
+ */
763
+ bootedAt: z2.string().optional(),
756
764
  source: z2.string(),
757
765
  // "base", "snapshot:<owner/name>", "fork:<owner/name>" (#79) or "backup:<id>" (#141)
758
766
  status: BoxStatusSchema,
@@ -817,7 +825,9 @@ var VolumeSchema = z2.object({
817
825
  /** Whether the owner slug is a user or an org. Only the control plane knows; it fills it in on `GET /volumes`. */
818
826
  ownerKind: z2.enum(["user", "org"]).optional(),
819
827
  /** The name of the host the volume lives on; only the control plane fills it in. It attaches only to a box there. */
820
- host: z2.string().optional()
828
+ host: z2.string().optional(),
829
+ /** The country code of that host (`RO`, `US`), when its admin gave one (#140). Only the control plane fills it in. */
830
+ country: z2.string().optional()
821
831
  });
822
832
  var MAX_VOLUME_GIB = 4096;
823
833
  var VOLUME_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
@@ -1089,6 +1099,7 @@ var LatestImagesSchema = z2.object({
1089
1099
  images: ImageIndexSchema.shape.images,
1090
1100
  checkedAt: z2.string().nullable()
1091
1101
  });
1102
+ var LatestServerSchema = z2.object({ version: z2.string().nullable(), checkedAt: z2.string().nullable() });
1092
1103
  var RecoveryReportSchema = z2.object({
1093
1104
  at: z2.string(),
1094
1105
  booted: z2.array(z2.string()),
@@ -1369,6 +1380,18 @@ var BalanceSchema = z2.object({
1369
1380
  balance: z2.number(),
1370
1381
  currency: z2.string(),
1371
1382
  topUps: z2.number(),
1383
+ /**
1384
+ * `topUps` split by where the money came from (#144), so a page can say "you added $X" and an org can
1385
+ * tell a top-up from a transfer: `topUps = added + welcome + transferredIn - transferredOut`. `added` is
1386
+ * card payments and an admin's top-ups (an admin's correction, negative, included); `welcome` the
1387
+ * welcome credit of a first card (`trial` rows); `transferredIn` what an owner moved into this org and
1388
+ * `transferredOut` what this user moved to their orgs, both positive. Promo credit is in none of them
1389
+ * (`promo`). Absent from a control plane older than these fields: 0.
1390
+ */
1391
+ added: z2.number().default(0),
1392
+ welcome: z2.number().default(0),
1393
+ transferredIn: z2.number().default(0),
1394
+ transferredOut: z2.number().default(0),
1372
1395
  spent: z2.number(),
1373
1396
  /** The first moment usage counts from: the slug's first top-up or redeemed code; null when it has none. */
1374
1397
  since: z2.string().nullable(),
@@ -1765,17 +1788,77 @@ import { setTimeout as sleep2 } from "timers/promises";
1765
1788
  import { Agent, request } from "undici";
1766
1789
 
1767
1790
  // ../sdk/src/machines.ts
1768
- import { z as z5 } from "zod";
1791
+ import { z as z6 } from "zod";
1769
1792
 
1770
- // ../shared/src/traffic.ts
1793
+ // ../shared/src/resources.ts
1771
1794
  import { z as z4 } from "zod";
1795
+ var RESOURCE_SLOT_MS = 5 * 6e4;
1796
+ var RESOURCE_KEEP_DAYS = 7;
1797
+ var RESOURCE_KEEP_MS = RESOURCE_KEEP_DAYS * 864e5;
1798
+ var whole = z4.number().int().nonnegative();
1799
+ var pct = z4.number().min(0).max(100);
1800
+ var small = whole.max(2 ** 31 - 1);
1801
+ var ResourceSlotRowSchema = z4.object({
1802
+ /** The host's box id. */
1803
+ boxId: z4.string(),
1804
+ owner: z4.string(),
1805
+ name: z4.string(),
1806
+ /** The slot's start, ms since the epoch. */
1807
+ slot: whole,
1808
+ vcpu: small,
1809
+ cpuMs: whole,
1810
+ wallMs: whole,
1811
+ cpuMaxPct: pct,
1812
+ memSamples: small,
1813
+ memSumMib: whole,
1814
+ memMaxMib: small,
1815
+ memTotalMib: small.nullable(),
1816
+ diskUsedBytes: whole.nullable(),
1817
+ diskTotalBytes: whole.nullable(),
1818
+ netInBytes: whole,
1819
+ netOutBytes: whole
1820
+ });
1821
+ var ResourceSlotsResponseSchema = z4.object({
1822
+ slots: z4.array(ResourceSlotRowSchema),
1823
+ next: whole
1824
+ });
1825
+ var ResourceSlotsPageSchema = z4.object({ slots: z4.array(z4.unknown()), next: whole });
1826
+ var figures = {
1827
+ /** Average and busiest minute, percent of the box's vCPUs; null when the CPU was not measured. */
1828
+ cpuPct: pct.nullable(),
1829
+ cpuMaxPct: pct.nullable(),
1830
+ /** Average and highest memory in use; null when the guest gave no answer (an image before base v0.7.0, or a guest that does not answer). */
1831
+ memUsedMib: whole.nullable(),
1832
+ memMaxMib: whole.nullable(),
1833
+ memTotalMib: whole.nullable(),
1834
+ /** The box's own disk as the guest last said. */
1835
+ diskUsedBytes: whole.nullable(),
1836
+ diskTotalBytes: whole.nullable(),
1837
+ netInBytes: whole,
1838
+ netOutBytes: whole
1839
+ };
1840
+ var ResourcePointSchema = z4.object({ at: z4.string(), ...figures });
1841
+ var ResourceReportSchema = z4.object({
1842
+ box: z4.string(),
1843
+ owner: z4.string(),
1844
+ since: z4.string(),
1845
+ until: z4.string(),
1846
+ stepMin: z4.number().int().positive(),
1847
+ /** The box's vCPUs as last measured; null without a row. */
1848
+ vcpu: whole.nullable(),
1849
+ totals: z4.object(figures),
1850
+ points: z4.array(ResourcePointSchema)
1851
+ });
1852
+
1853
+ // ../shared/src/traffic.ts
1854
+ import { z as z5 } from "zod";
1772
1855
  var TRAFFIC_SLOT_MS = 5 * 6e4;
1773
1856
  var TRAFFIC_KEEP_DAYS = 7;
1774
1857
  var TRAFFIC_KEEP_MS = TRAFFIC_KEEP_DAYS * 864e5;
1775
1858
  var LATENCY_BUCKETS_MS = [5, 10, 25, 50, 100, 250, 500, 1e3, 2500, 5e3, 1e4, 3e4];
1776
1859
  var LATENCY_BUCKET_COUNT = LATENCY_BUCKETS_MS.length + 1;
1777
- var count = z4.number().int().nonnegative();
1778
- var figures = {
1860
+ var count = z5.number().int().nonnegative();
1861
+ var figures2 = {
1779
1862
  requests: count,
1780
1863
  s2xx: count,
1781
1864
  s3xx: count,
@@ -1790,28 +1873,28 @@ var figures = {
1790
1873
  p50Ms: count.nullable(),
1791
1874
  p95Ms: count.nullable()
1792
1875
  };
1793
- var TrafficPointSchema = z4.object({ at: z4.string(), ...figures });
1794
- var TrafficReportSchema = z4.object({
1795
- box: z4.string(),
1796
- owner: z4.string(),
1797
- since: z4.string(),
1798
- until: z4.string(),
1799
- stepMin: z4.number().int().positive(),
1876
+ var TrafficPointSchema = z5.object({ at: z5.string(), ...figures2 });
1877
+ var TrafficReportSchema = z5.object({
1878
+ box: z5.string(),
1879
+ owner: z5.string(),
1880
+ since: z5.string(),
1881
+ until: z5.string(),
1882
+ stepMin: z5.number().int().positive(),
1800
1883
  /** The one host name asked for; null for all of the box's. */
1801
- host: z4.string().nullable(),
1884
+ host: z5.string().nullable(),
1802
1885
  /** Every host name of the box with traffic in the range, whatever `host` is: what a filter can offer. */
1803
- hosts: z4.array(z4.string()),
1804
- totals: z4.object(figures),
1805
- points: z4.array(TrafficPointSchema)
1886
+ hosts: z5.array(z5.string()),
1887
+ totals: z5.object(figures2),
1888
+ points: z5.array(TrafficPointSchema)
1806
1889
  });
1807
- var BoxTrafficSchema = z4.object({ box: z4.string(), owner: z4.string(), ...figures });
1808
- var TrafficOverviewSchema = z4.object({
1809
- since: z4.string(),
1810
- until: z4.string(),
1811
- stepMin: z4.number().int().positive(),
1812
- totals: z4.object(figures),
1813
- points: z4.array(TrafficPointSchema),
1814
- boxes: z4.array(BoxTrafficSchema)
1890
+ var BoxTrafficSchema = z5.object({ box: z5.string(), owner: z5.string(), ...figures2 });
1891
+ var TrafficOverviewSchema = z5.object({
1892
+ since: z5.string(),
1893
+ until: z5.string(),
1894
+ stepMin: z5.number().int().positive(),
1895
+ totals: z5.object(figures2),
1896
+ points: z5.array(TrafficPointSchema),
1897
+ boxes: z5.array(BoxTrafficSchema)
1815
1898
  });
1816
1899
 
1817
1900
  // ../sdk/src/errors.ts
@@ -1924,7 +2007,7 @@ var Machines = class {
1924
2007
  ports;
1925
2008
  /** Every box the caller can read (their own and their orgs'), sorted by owner then name. */
1926
2009
  list(opts = {}) {
1927
- return this.transport.request("GET", `/machines${listQuery(opts)}`, z5.array(MachineSchema), { org: opts.org });
2010
+ return this.transport.request("GET", `/machines${listQuery(opts)}`, z6.array(MachineSchema), { org: opts.org });
1928
2011
  }
1929
2012
  /**
1930
2013
  * One box, found in the listing (the API has no route for a single box). `slug/name` looks in that
@@ -1938,7 +2021,7 @@ var Machines = class {
1938
2021
  async find(name, orgOpt, timeoutMs) {
1939
2022
  const slash = name.indexOf("/");
1940
2023
  const [org, bare] = slash === -1 ? [orgOpt, name] : [name.slice(0, slash), name.slice(slash + 1)];
1941
- const listing = await this.transport.request("GET", "/machines", z5.array(MachineSchema), { org, timeoutMs });
2024
+ const listing = await this.transport.request("GET", "/machines", z6.array(MachineSchema), { org, timeoutMs });
1942
2025
  const named = listing.filter((m) => m.name === bare && (slash === -1 || slugOf2(m.owner) === org));
1943
2026
  if (named.length <= 1) {
1944
2027
  if (named[0] !== void 0) return named[0];
@@ -1972,7 +2055,7 @@ var Machines = class {
1972
2055
  }
1973
2056
  /** Remove the box and its disk. */
1974
2057
  async remove(name, opts = {}) {
1975
- await this.transport.request("DELETE", box(name), z5.undefined(), { org: opts.org });
2058
+ await this.transport.request("DELETE", box(name), z6.undefined(), { org: opts.org });
1976
2059
  }
1977
2060
  /** Boot a stopped box. */
1978
2061
  start(name, opts = {}) {
@@ -1982,6 +2065,15 @@ var Machines = class {
1982
2065
  stop(name, opts = {}) {
1983
2066
  return this.transport.request("POST", box(name, "/stop"), MachineSchema, { org: opts.org });
1984
2067
  }
2068
+ /**
2069
+ * Stop and boot again in one step (#143); what would refuse the boot (credit, room) refuses before the stop,
2070
+ * and a boot that fails after it leaves the box stopped, with an error that says so. A running or paused
2071
+ * box shuts down cleanly, a hibernated one loses its saved memory (as `stop` does), a stopped one just boots.
2072
+ * Costs and checks what `start` does.
2073
+ */
2074
+ restart(name, opts = {}) {
2075
+ return this.transport.request("POST", box(name, "/restart"), MachineSchema, { body: opts.force ? { force: true } : void 0, org: opts.org });
2076
+ }
1985
2077
  /** Freeze the running box in memory (standby). */
1986
2078
  pause(name, opts = {}) {
1987
2079
  return this.transport.request("POST", box(name, "/pause"), MachineSchema, { org: opts.org });
@@ -2115,6 +2207,15 @@ var Machines = class {
2115
2207
  traffic(name, opts = {}) {
2116
2208
  return this.transport.request("GET", box(name, `/traffic${trafficQuery(opts)}`), TrafficReportSchema, { org: opts.org });
2117
2209
  }
2210
+ /**
2211
+ * The box's CPU, memory, disk and network over time, measured by its host once a minute while it runs and
2212
+ * kept 7 days in five-minute slots: average and peak CPU as a percent of its vCPUs, average and peak memory,
2213
+ * disk as last seen, network bytes each way. The last 24 hours by default. Memory and disk are null when the
2214
+ * box itself gave no answer.
2215
+ */
2216
+ resources(name, opts = {}) {
2217
+ return this.transport.request("GET", box(name, `/resources${trafficQuery(opts)}`), ResourceReportSchema, { org: opts.org });
2218
+ }
2118
2219
  };
2119
2220
  var iso = (d) => typeof d === "string" ? d : d.toISOString();
2120
2221
  function trafficQuery(opts) {
@@ -2139,7 +2240,7 @@ var slugOf2 = (owner) => {
2139
2240
  };
2140
2241
 
2141
2242
  // ../sdk/src/snapshots.ts
2142
- import { z as z6 } from "zod";
2243
+ import { z as z7 } from "zod";
2143
2244
  var Snapshots = class {
2144
2245
  constructor(transport) {
2145
2246
  this.transport = transport;
@@ -2147,19 +2248,19 @@ var Snapshots = class {
2147
2248
  transport;
2148
2249
  /** Every snapshot the caller can read. */
2149
2250
  list(opts = {}) {
2150
- return this.transport.request("GET", `/snapshots${listQuery(opts)}`, z6.array(SnapshotSchema), { org: opts.org });
2251
+ return this.transport.request("GET", `/snapshots${listQuery(opts)}`, z7.array(SnapshotSchema), { org: opts.org });
2151
2252
  }
2152
2253
  /** Snapshot box `req.box` as `req.name` (`replace`: retake one that exists). The box is paused while it is taken. */
2153
2254
  create(req, opts = {}) {
2154
2255
  return this.transport.request("POST", "/snapshots", SnapshotSchema, { body: req, org: opts.org });
2155
2256
  }
2156
2257
  async remove(name, opts = {}) {
2157
- await this.transport.request("DELETE", `/snapshots/${encodeURIComponent(name)}`, z6.undefined(), { org: opts.org });
2258
+ await this.transport.request("DELETE", `/snapshots/${encodeURIComponent(name)}`, z7.undefined(), { org: opts.org });
2158
2259
  }
2159
2260
  };
2160
2261
 
2161
2262
  // ../sdk/src/transport.ts
2162
- import { z as z7 } from "zod";
2263
+ import { z as z8 } from "zod";
2163
2264
  var Transport = class {
2164
2265
  baseUrl;
2165
2266
  org;
@@ -2233,7 +2334,7 @@ var Transport = class {
2233
2334
  }
2234
2335
  }
2235
2336
  };
2236
- var LooseApiErrorSchema = z7.object({ error: z7.string(), code: z7.string().optional() });
2337
+ var LooseApiErrorSchema = z8.object({ error: z8.string(), code: z8.string().optional() });
2237
2338
  function safeJson(text2) {
2238
2339
  try {
2239
2340
  return JSON.parse(text2);
@@ -2250,8 +2351,20 @@ function errorCode(err) {
2250
2351
  return void 0;
2251
2352
  }
2252
2353
 
2354
+ // ../sdk/src/hooks.ts
2355
+ var Hooks = class {
2356
+ constructor(transport) {
2357
+ this.transport = transport;
2358
+ }
2359
+ transport;
2360
+ /** Every readable slug's hooks (`org`: one org's). */
2361
+ list(opts = {}) {
2362
+ return this.transport.request("GET", "/hooks", WakeHookListSchema, { org: opts.org });
2363
+ }
2364
+ };
2365
+
2253
2366
  // ../sdk/src/integrations.ts
2254
- import { z as z8 } from "zod";
2367
+ import { z as z9 } from "zod";
2255
2368
  var Integrations = class {
2256
2369
  constructor(transport) {
2257
2370
  this.transport = transport;
@@ -2259,12 +2372,12 @@ var Integrations = class {
2259
2372
  transport;
2260
2373
  /** Each readable slug's state for each integration (`org`: one org's), connected or not; never a credential. */
2261
2374
  list(opts = {}) {
2262
- return this.transport.request("GET", "/integrations", z8.array(IntegrationSchema), { org: opts.org });
2375
+ return this.transport.request("GET", "/integrations", z9.array(IntegrationSchema), { org: opts.org });
2263
2376
  }
2264
2377
  };
2265
2378
 
2266
2379
  // ../sdk/src/volumes.ts
2267
- import { z as z9 } from "zod";
2380
+ import { z as z10 } from "zod";
2268
2381
  var volume = (name, rest = "") => `/volumes/${encodeURIComponent(name)}${rest}`;
2269
2382
  var Volumes = class {
2270
2383
  constructor(transport) {
@@ -2272,7 +2385,7 @@ var Volumes = class {
2272
2385
  }
2273
2386
  transport;
2274
2387
  list(opts = {}) {
2275
- return this.transport.request("GET", `/volumes${listQuery(opts)}`, z9.array(VolumeSchema), { org: opts.org });
2388
+ return this.transport.request("GET", `/volumes${listQuery(opts)}`, z10.array(VolumeSchema), { org: opts.org });
2276
2389
  }
2277
2390
  /**
2278
2391
  * Make a volume of `sizeGib` GiB. Through the cloud `box` is required: the volume is made on that
@@ -2295,7 +2408,7 @@ var Volumes = class {
2295
2408
  }
2296
2409
  /** Remove the volume and its data; it must be detached first. */
2297
2410
  async remove(name, opts = {}) {
2298
- await this.transport.request("DELETE", volume(name), z9.undefined(), { org: opts.org });
2411
+ await this.transport.request("DELETE", volume(name), z10.undefined(), { org: opts.org });
2299
2412
  }
2300
2413
  };
2301
2414
 
@@ -2317,6 +2430,7 @@ var Kvbox = class {
2317
2430
  snapshots;
2318
2431
  volumes;
2319
2432
  integrations;
2433
+ hooks;
2320
2434
  transport;
2321
2435
  constructor(opts = {}) {
2322
2436
  this.transport = new Transport({
@@ -2330,6 +2444,7 @@ var Kvbox = class {
2330
2444
  this.snapshots = new Snapshots(this.transport);
2331
2445
  this.volumes = new Volumes(this.transport);
2332
2446
  this.integrations = new Integrations(this.transport);
2447
+ this.hooks = new Hooks(this.transport);
2333
2448
  }
2334
2449
  /** The API this client talks to, without a trailing slash. */
2335
2450
  get baseUrl() {
@@ -2345,41 +2460,41 @@ var Kvbox = class {
2345
2460
  };
2346
2461
 
2347
2462
  // src/client.ts
2348
- import { z as z14 } from "zod";
2463
+ import { z as z15 } from "zod";
2349
2464
 
2350
2465
  // ../shared/src/usage.ts
2351
- import { z as z10 } from "zod";
2352
- var PricingSchema = z10.object({
2353
- currency: z10.string().min(1),
2354
- vcpuHour: z10.number().nonnegative(),
2355
- ramGibHour: z10.number().nonnegative(),
2356
- diskGibHour: z10.number().nonnegative(),
2357
- volumeHour: z10.number().nonnegative().default(0),
2358
- volumeGibHour: z10.number().nonnegative().default(0),
2359
- diskIncludedGib: z10.number().int().nonnegative().default(0),
2466
+ import { z as z11 } from "zod";
2467
+ var PricingSchema = z11.object({
2468
+ currency: z11.string().min(1),
2469
+ vcpuHour: z11.number().nonnegative(),
2470
+ ramGibHour: z11.number().nonnegative(),
2471
+ diskGibHour: z11.number().nonnegative(),
2472
+ volumeHour: z11.number().nonnegative().default(0),
2473
+ volumeGibHour: z11.number().nonnegative().default(0),
2474
+ diskIncludedGib: z11.number().int().nonnegative().default(0),
2360
2475
  /**
2361
2476
  * Object storage (#182): an hour of a slug's storage existing, whatever it holds, which covers its
2362
2477
  * hidden box and the first `storageIncludedGib` of its size; each GiB above that is `storageGibHour`.
2363
2478
  * A price list from before object storage charges nothing for it.
2364
2479
  */
2365
- storageHour: z10.number().nonnegative().default(0),
2366
- storageGibHour: z10.number().nonnegative().default(0),
2367
- storageIncludedGib: z10.number().int().nonnegative().default(0),
2480
+ storageHour: z11.number().nonnegative().default(0),
2481
+ storageGibHour: z11.number().nonnegative().default(0),
2482
+ storageIncludedGib: z11.number().int().nonnegative().default(0),
2368
2483
  /** The cron service (#190): an hour of one cron service existing, whatever it holds or fires. A price list from before it charges nothing. */
2369
- cronHour: z10.number().nonnegative().default(0),
2484
+ cronHour: z11.number().nonnegative().default(0),
2370
2485
  /**
2371
2486
  * One backup a person starts, of anything, charged once it is ready (decision "A backup taken by hand
2372
2487
  * costs a flat price…"); a failed one costs nothing. A price list from before it charges nothing.
2373
2488
  */
2374
- backup: z10.number().nonnegative().default(0),
2489
+ backup: z11.number().nonnegative().default(0),
2375
2490
  /**
2376
2491
  * One nightly backup of a box, a volume or the object storage, charged once it is ready (decision "A nightly
2377
2492
  * backup you switch on is charged…"): their switch is off until someone turns it on. A managed database's
2378
2493
  * nightly backup, on from its creation, is included in its price. A price list from before it charges nothing.
2379
2494
  */
2380
- scheduledBackup: z10.number().nonnegative().default(0)
2495
+ scheduledBackup: z11.number().nonnegative().default(0)
2381
2496
  });
2382
- var PriceListSchema = PricingSchema.extend({ welcomeCredit: z10.number().nonnegative() });
2497
+ var PriceListSchema = PricingSchema.extend({ welcomeCredit: z11.number().nonnegative() });
2383
2498
  var HOUR_MS = 36e5;
2384
2499
  var round = (n2, places) => Math.round(n2 * 10 ** places) / 10 ** places;
2385
2500
  function costOf(t, pricing) {
@@ -2407,86 +2522,86 @@ function sumUsage(items, pricing) {
2407
2522
  var DAY_MS = 24 * HOUR_MS;
2408
2523
 
2409
2524
  // ../shared/src/managed.ts
2410
- import { z as z11 } from "zod";
2411
- var PriceSchema = z11.object({ perMonth: z11.number(), storagePerMonth: z11.number(), currency: z11.string() });
2412
- var ManagedCatalogEntrySchema = z11.object({
2525
+ import { z as z12 } from "zod";
2526
+ var PriceSchema = z12.object({ perMonth: z12.number(), storagePerMonth: z12.number(), currency: z12.string() });
2527
+ var ManagedCatalogEntrySchema = z12.object({
2413
2528
  /** The kind, as in `/managed/<kind>`: `postgres`. */
2414
- kind: z11.string(),
2529
+ kind: z12.string(),
2415
2530
  /** The CLI command for it: `pg` (`kvbox pg create …`). */
2416
- command: z11.string(),
2417
- title: z11.string(),
2418
- description: z11.string(),
2531
+ command: z12.string(),
2532
+ title: z12.string(),
2533
+ description: z12.string(),
2419
2534
  /** The version a new one runs, as shown: `18`. */
2420
- version: z11.string(),
2535
+ version: z12.string(),
2421
2536
  /** The port a linked box reaches it on. */
2422
- port: z11.number().int(),
2537
+ port: z12.number().int(),
2423
2538
  /** The port `public on` opens behind a host port: `port` again unless the kind serves TLS on another. */
2424
- publicPort: z11.number().int(),
2539
+ publicPort: z12.number().int(),
2425
2540
  /** Its guide, as a URL. */
2426
- docs: z11.string().optional(),
2427
- storage: z11.object({ defaultGib: z11.number().int(), minGib: z11.number().int(), maxGib: z11.number().int() }),
2541
+ docs: z12.string().optional(),
2542
+ storage: z12.object({ defaultGib: z12.number().int(), minGib: z12.number().int(), maxGib: z12.number().int() }),
2428
2543
  /**
2429
2544
  * What create takes of this kind alone, beside what every kind takes (name, password, storage, near): a
2430
2545
  * flag and a form field each, all optional, `default` in words.
2431
2546
  */
2432
- options: z11.array(z11.object({ name: z11.string(), title: z11.string(), description: z11.string(), default: z11.string() })),
2547
+ options: z12.array(z12.object({ name: z12.string(), title: z12.string(), description: z12.string(), default: z12.string() })),
2433
2548
  /** A month of it running with the default storage, and each further GB of storage. */
2434
- price: PriceSchema.extend({ storageGibPerMonth: z11.number() }),
2549
+ price: PriceSchema.extend({ storageGibPerMonth: z12.number() }),
2435
2550
  /** Whether a host answering now can run it. */
2436
- available: z11.boolean()
2551
+ available: z12.boolean()
2437
2552
  });
2438
- var CreateManagedRequest = z11.object({
2439
- name: z11.string(),
2553
+ var CreateManagedRequest = z12.object({
2554
+ name: z12.string(),
2440
2555
  /** The kind's own options by name (its catalog entry lists them); the kind checks them. */
2441
- options: z11.record(z11.string(), z11.string()).optional(),
2442
- password: z11.string().optional(),
2443
- storageGib: z11.number().int().optional(),
2556
+ options: z12.record(z12.string(), z12.string()).optional(),
2557
+ password: z12.string().optional(),
2558
+ storageGib: z12.number().int().optional(),
2444
2559
  /** Place it on the host of this box, so the box can be linked to it. */
2445
- near: z11.string().optional(),
2560
+ near: z12.string().optional(),
2446
2561
  /**
2447
2562
  * A backup of a database of the same kind and major version, of the same account (#186): the new
2448
2563
  * service starts on its data, a removed service's included. Its settings (Postgres: database, user)
2449
2564
  * are the backup's; the password is the new one.
2450
2565
  */
2451
- fromBackup: z11.string().optional()
2566
+ fromBackup: z12.string().optional()
2452
2567
  });
2453
- var ManagedHealthSchema = z11.object({
2568
+ var ManagedHealthSchema = z12.object({
2454
2569
  /** Its first start has finished: it has set itself up on its storage. */
2455
- ready: z11.boolean(),
2570
+ ready: z12.boolean(),
2456
2571
  /** It accepts connections. */
2457
- accepting: z11.boolean(),
2458
- version: z11.string(),
2572
+ accepting: z12.boolean(),
2573
+ version: z12.string(),
2459
2574
  /** The storage volume: what is used of it and its size. */
2460
- storageUsedBytes: z11.number().optional(),
2461
- storageTotalBytes: z11.number().optional(),
2575
+ storageUsedBytes: z12.number().optional(),
2576
+ storageTotalBytes: z12.number().optional(),
2462
2577
  /** What else the kind reports, ready to show: `{title: "Connections", value: "3"}`. */
2463
- facts: z11.array(z11.object({ title: z11.string(), value: z11.string() }))
2578
+ facts: z12.array(z12.object({ title: z12.string(), value: z12.string() }))
2464
2579
  });
2465
- var UrlsSchema = z11.object({ private: z11.string(), public: z11.string().optional() });
2466
- var ManagedSchema = z11.object({
2467
- kind: z11.string(),
2468
- name: z11.string(),
2580
+ var UrlsSchema = z12.object({ private: z12.string(), public: z12.string().optional() });
2581
+ var ManagedSchema = z12.object({
2582
+ kind: z12.string(),
2583
+ name: z12.string(),
2469
2584
  /** The owning slug, bare. */
2470
- owner: z11.string(),
2471
- ownerKind: z11.enum(["user", "org"]),
2585
+ owner: z12.string(),
2586
+ ownerKind: z12.enum(["user", "org"]),
2472
2587
  /** `running`, `stopped` (storage only is charged), `hibernated` or `standby` (out of credit), `unknown` (its host does not answer). */
2473
2588
  status: BoxStatusSchema,
2474
2589
  /** The catalog version: `18`. */
2475
- version: z11.string(),
2590
+ version: z12.string(),
2476
2591
  /** What the kind keeps of its create options, defaults filled in: `{database, user}` for Postgres, `{}` for a kind with none. */
2477
- settings: z11.record(z11.string(), z11.string()),
2478
- storageGib: z11.number().int(),
2592
+ settings: z12.record(z12.string(), z12.string()),
2593
+ storageGib: z12.number().int(),
2479
2594
  /** Where a linked box reaches it: `<name>.<slug>.kvbox` (resolves from a box of any slug it is linked to) and the port. */
2480
- private: z11.object({ host: z11.string(), port: z11.number().int() }),
2595
+ private: z12.object({ host: z12.string(), port: z12.number().int() }),
2481
2596
  /** Where the internet reaches it, null while it is not public. The port is its own for its whole life. */
2482
- public: z11.object({ host: z11.string(), port: z11.number().int() }).nullable(),
2597
+ public: z12.object({ host: z12.string(), port: z12.number().int() }).nullable(),
2483
2598
  /** The boxes linked to it, as the caller would name them. */
2484
- links: z11.array(z11.string()),
2599
+ links: z12.array(z12.string()),
2485
2600
  /** The name of the host it runs on, for `--near` and links. */
2486
- host: z11.string(),
2487
- country: z11.string().optional(),
2488
- createdBy: z11.string().nullable(),
2489
- createdAt: z11.string(),
2601
+ host: z12.string(),
2602
+ country: z12.string().optional(),
2603
+ createdBy: z12.string().nullable(),
2604
+ createdAt: z12.string(),
2490
2605
  /** Connection strings with the password as `****`. */
2491
2606
  urls: UrlsSchema,
2492
2607
  price: PriceSchema,
@@ -2495,232 +2610,232 @@ var ManagedSchema = z11.object({
2495
2610
  /** Only in `GET /managed/<kind>/<name>` (asked live): null when it is not running or did not answer. */
2496
2611
  health: ManagedHealthSchema.nullable().optional()
2497
2612
  });
2498
- var ManagedSecretSchema = z11.object({ password: z11.string(), urls: UrlsSchema });
2613
+ var ManagedSecretSchema = z12.object({ password: z12.string(), urls: UrlsSchema });
2499
2614
  var CreatedManagedSchema = ManagedSchema.extend({
2500
2615
  secret: ManagedSecretSchema,
2501
2616
  /** The backup it was made from (`fromBackup`), when it was. */
2502
- fromBackup: z11.string().optional()
2503
- });
2504
- var ResetPasswordRequest = z11.object({ password: z11.string().optional() });
2505
- var SetPublicRequest = z11.object({ on: z11.boolean() });
2506
- var ManagedLinkRequest = z11.object({ box: z11.string() });
2507
- var GrowManagedRequest = z11.object({ storageGib: z11.number().int() });
2508
- var ManagedBackupSchema = z11.object({
2509
- id: z11.string(),
2510
- owner: z11.string(),
2511
- kind: z11.string(),
2512
- name: z11.string(),
2513
- version: z11.string(),
2514
- status: z11.enum(BACKUP_STATUSES),
2617
+ fromBackup: z12.string().optional()
2618
+ });
2619
+ var ResetPasswordRequest = z12.object({ password: z12.string().optional() });
2620
+ var SetPublicRequest = z12.object({ on: z12.boolean() });
2621
+ var ManagedLinkRequest = z12.object({ box: z12.string() });
2622
+ var GrowManagedRequest = z12.object({ storageGib: z12.number().int() });
2623
+ var ManagedBackupSchema = z12.object({
2624
+ id: z12.string(),
2625
+ owner: z12.string(),
2626
+ kind: z12.string(),
2627
+ name: z12.string(),
2628
+ version: z12.string(),
2629
+ status: z12.enum(BACKUP_STATUSES),
2515
2630
  /** Why it failed; null otherwise. */
2516
- error: z11.string().nullable(),
2631
+ error: z12.string().nullable(),
2517
2632
  /** The service's storage when taken. */
2518
- diskBytes: z11.number().int().nullable(),
2633
+ diskBytes: z12.number().int().nullable(),
2519
2634
  /** What it holds: the slots that are not all zeros. */
2520
- dataBytes: z11.number().int().nullable(),
2635
+ dataBytes: z12.number().int().nullable(),
2521
2636
  /** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
2522
- uploadedBytes: z11.number().int().nullable(),
2637
+ uploadedBytes: z12.number().int().nullable(),
2523
2638
  /** Who asked for it; for a scheduled one, the database's creator. */
2524
- createdBy: z11.string().nullable(),
2639
+ createdBy: z12.string().nullable(),
2525
2640
  /** Started by the database's backup schedule, not by a person: it does not count toward the daily limit. */
2526
- scheduled: z11.boolean().default(false),
2527
- createdAt: z11.string(),
2528
- finishedAt: z11.string().nullable()
2641
+ scheduled: z12.boolean().default(false),
2642
+ createdAt: z12.string(),
2643
+ finishedAt: z12.string().nullable()
2529
2644
  });
2530
2645
 
2531
2646
  // ../shared/src/cron.ts
2532
- import { z as z12 } from "zod";
2647
+ import { z as z13 } from "zod";
2533
2648
  var DEFAULT_CRON_COMMAND_TIMEOUT_SEC = 600;
2534
2649
  var MAX_CRON_COMMAND_TIMEOUT_SEC = 3600;
2535
2650
  var CRON_RUN_LOG_DIR = "/var/log/kvbox/runs";
2536
2651
  var CRON_METHODS = ["GET", "POST"];
2537
2652
  var CRON_OUTCOMES = ["running", "ok", "failed", "timeout", "no-credit", "box-stopped", "host-down", "host-outdated", "lost", "still-running", "box-outdated"];
2538
- var CronServiceSchema = z12.object({
2539
- owner: z12.string(),
2540
- ownerKind: z12.enum(["user", "org"]),
2541
- name: z12.string(),
2653
+ var CronServiceSchema = z13.object({
2654
+ owner: z13.string(),
2655
+ ownerKind: z13.enum(["user", "org"]),
2656
+ name: z13.string(),
2542
2657
  /** Runs kept per trigger. */
2543
- keepRuns: z12.number().int(),
2544
- triggers: z12.number().int(),
2545
- createdBy: z12.string().nullable(),
2546
- createdAt: z12.string(),
2658
+ keepRuns: z13.number().int(),
2659
+ triggers: z13.number().int(),
2660
+ createdBy: z13.string().nullable(),
2661
+ createdAt: z13.string(),
2547
2662
  /** What it costs while it exists; on the answer to `POST /cron` only. */
2548
- price: z12.object({ perMonth: z12.number(), currency: z12.string() }).optional()
2663
+ price: z13.object({ perMonth: z13.number(), currency: z13.string() }).optional()
2549
2664
  });
2550
2665
  var triggerCommon = {
2551
- id: z12.string(),
2552
- service: z12.string(),
2553
- owner: z12.string(),
2666
+ id: z13.string(),
2667
+ service: z13.string(),
2668
+ owner: z13.string(),
2554
2669
  /** The box it acts on; a trigger is removed with its box. */
2555
- box: z12.string(),
2670
+ box: z13.string(),
2556
2671
  /** Five fields, `minute hour day-of-month month day-of-week`. */
2557
- expr: z12.string(),
2672
+ expr: z13.string(),
2558
2673
  /** An IANA zone (`Europe/Bucharest`) the expression is read in; `UTC` unless said. */
2559
- timezone: z12.string(),
2674
+ timezone: z13.string(),
2560
2675
  /** False: paused, it fires again when resumed. */
2561
- enabled: z12.boolean(),
2676
+ enabled: z13.boolean(),
2562
2677
  /** When it fires next (ISO); null while paused. */
2563
- nextRunAt: z12.string().nullable(),
2564
- lastRunAt: z12.string().nullable(),
2565
- lastOutcome: z12.enum(CRON_OUTCOMES).nullable(),
2566
- createdBy: z12.string().nullable(),
2567
- createdAt: z12.string()
2678
+ nextRunAt: z13.string().nullable(),
2679
+ lastRunAt: z13.string().nullable(),
2680
+ lastOutcome: z13.enum(CRON_OUTCOMES).nullable(),
2681
+ createdBy: z13.string().nullable(),
2682
+ createdAt: z13.string()
2568
2683
  };
2569
- var CronHttpTriggerSchema = z12.object({
2684
+ var CronHttpTriggerSchema = z13.object({
2570
2685
  ...triggerCommon,
2571
- kind: z12.literal("http"),
2572
- method: z12.enum(CRON_METHODS),
2573
- port: z12.number().int(),
2686
+ kind: z13.literal("http"),
2687
+ method: z13.enum(CRON_METHODS),
2688
+ port: z13.number().int(),
2574
2689
  /** Path and query, starting with `/`. */
2575
- path: z12.string()
2690
+ path: z13.string()
2576
2691
  });
2577
- var CronCommandTriggerSchema = z12.object({
2692
+ var CronCommandTriggerSchema = z13.object({
2578
2693
  ...triggerCommon,
2579
- kind: z12.literal("command"),
2694
+ kind: z13.literal("command"),
2580
2695
  /** Run by a login shell as the box's user, in its home. */
2581
- command: z12.string(),
2696
+ command: z13.string(),
2582
2697
  /** The command is stopped after this long. */
2583
- timeoutSec: z12.number().int()
2698
+ timeoutSec: z13.number().int()
2584
2699
  });
2585
- var CronTriggerSchema = z12.discriminatedUnion("kind", [CronHttpTriggerSchema, CronCommandTriggerSchema]);
2586
- var CronRunSchema = z12.object({
2700
+ var CronTriggerSchema = z13.discriminatedUnion("kind", [CronHttpTriggerSchema, CronCommandTriggerSchema]);
2701
+ var CronRunSchema = z13.object({
2587
2702
  /** The slot this run was for (ISO); a run asked for by hand has the moment it was asked. */
2588
- scheduledFor: z12.string(),
2589
- startedAt: z12.string(),
2703
+ scheduledFor: z13.string(),
2704
+ startedAt: z13.string(),
2590
2705
  /** Null while `running`, and for a run that was never sent. */
2591
- durationMs: z12.number().int().nullable(),
2706
+ durationMs: z13.number().int().nullable(),
2592
2707
  /** The box's HTTP status; null when it never answered, and for a command. */
2593
- status: z12.number().int().nullable(),
2708
+ status: z13.number().int().nullable(),
2594
2709
  /** A command's exit code (128 + the signal when one ended it); null until it ends, and for a request. */
2595
- exitCode: z12.number().int().nullable(),
2710
+ exitCode: z13.number().int().nullable(),
2596
2711
  /** The files in the box that hold what a command printed (a shell pattern, `cron-<n>.*`); null for a request and for a command that never started. */
2597
- output: z12.string().nullable(),
2598
- outcome: z12.enum(CRON_OUTCOMES),
2712
+ output: z13.string().nullable(),
2713
+ outcome: z13.enum(CRON_OUTCOMES),
2599
2714
  /** Why it did not end `ok`, in a line. */
2600
- error: z12.string().nullable(),
2715
+ error: z13.string().nullable(),
2601
2716
  /** The box was hibernated and this run woke it. */
2602
- woke: z12.boolean()
2717
+ woke: z13.boolean()
2603
2718
  });
2604
- var CronCatalogSchema = z12.object({
2605
- price: z12.object({ perMonth: z12.number(), currency: z12.string() }),
2606
- maxServices: z12.number().int(),
2607
- maxTriggers: z12.number().int(),
2608
- keepRuns: z12.number().int(),
2719
+ var CronCatalogSchema = z13.object({
2720
+ price: z13.object({ perMonth: z13.number(), currency: z13.string() }),
2721
+ maxServices: z13.number().int(),
2722
+ maxTriggers: z13.number().int(),
2723
+ keepRuns: z13.number().int(),
2609
2724
  /** The shortest time between two runs of one trigger, in seconds. */
2610
- minIntervalSeconds: z12.number().int(),
2725
+ minIntervalSeconds: z13.number().int(),
2611
2726
  /** How long a box has to answer, in seconds. */
2612
- timeoutSeconds: z12.number().int(),
2727
+ timeoutSeconds: z13.number().int(),
2613
2728
  /** How long a command may run: unless the trigger says, and at most. */
2614
- commandTimeoutSeconds: z12.number().int(),
2615
- maxCommandTimeoutSeconds: z12.number().int(),
2616
- docs: z12.string().optional()
2617
- });
2618
- var CreateCronServiceRequest = z12.object({ name: z12.string() });
2619
- var CreateCronTriggerRequest = z12.object({
2620
- box: z12.string().min(1),
2621
- expr: z12.string().min(1),
2622
- timezone: z12.string().optional(),
2729
+ commandTimeoutSeconds: z13.number().int(),
2730
+ maxCommandTimeoutSeconds: z13.number().int(),
2731
+ docs: z13.string().optional()
2732
+ });
2733
+ var CreateCronServiceRequest = z13.object({ name: z13.string() });
2734
+ var CreateCronTriggerRequest = z13.object({
2735
+ box: z13.string().min(1),
2736
+ expr: z13.string().min(1),
2737
+ timezone: z13.string().optional(),
2623
2738
  /** A request: `port`, with `method` and `path`. */
2624
- method: z12.enum(CRON_METHODS).optional(),
2625
- port: z12.number().int().min(1).max(65535).optional(),
2626
- path: z12.string().optional(),
2739
+ method: z13.enum(CRON_METHODS).optional(),
2740
+ port: z13.number().int().min(1).max(65535).optional(),
2741
+ path: z13.string().optional(),
2627
2742
  /** Or a command, with `timeoutSec`; exactly one of `port` and `command`. */
2628
- command: z12.string().optional(),
2629
- timeoutSec: z12.number().int().optional()
2743
+ command: z13.string().optional(),
2744
+ timeoutSec: z13.number().int().optional()
2630
2745
  });
2631
- var UpdateCronTriggerRequest = z12.object({ enabled: z12.boolean() });
2746
+ var UpdateCronTriggerRequest = z13.object({ enabled: z13.boolean() });
2632
2747
  var cronTarget = (t) => t.kind === "command" ? `${t.box}$ ${t.command}` : `${t.method} ${t.box}:${t.port}${t.path}`;
2633
2748
 
2634
2749
  // ../shared/src/storage.ts
2635
- import { z as z13 } from "zod";
2636
- var RegionSchema = z13.object({ name: z13.string(), country: z13.string().nullable() });
2750
+ import { z as z14 } from "zod";
2751
+ var RegionSchema = z14.object({ name: z14.string(), country: z14.string().nullable() });
2637
2752
  var MAX_PUBLIC_BUCKETS = 10;
2638
2753
  var STORAGE_BOX_SUBDOMAINS = MAX_PUBLIC_BUCKETS + 2;
2639
- var ObjectStorageSchema = z13.object({
2640
- owner: z13.string(),
2641
- ownerKind: z13.enum(["user", "org"]),
2754
+ var ObjectStorageSchema = z14.object({
2755
+ owner: z14.string(),
2756
+ ownerKind: z14.enum(["user", "org"]),
2642
2757
  /** `https://s3-<slug>.<domain>`: what an S3 client is given, with path-style addressing. Null while the address is not claimed. */
2643
- endpoint: z13.string().nullable(),
2758
+ endpoint: z14.string().nullable(),
2644
2759
  /** The S3 region every client of it signs with (`ro-west-1`): its host's when it was made. */
2645
- region: z13.string(),
2760
+ region: z14.string(),
2646
2761
  /** The most it may hold. */
2647
- sizeGib: z13.number().int(),
2762
+ sizeGib: z14.number().int(),
2648
2763
  /** `running` when it answers; `unknown` while its host is not heard from. */
2649
2764
  status: BoxStatusSchema,
2650
2765
  /** With `?live=1`, when the storage answered: what is on its disk, and the disk's real size. */
2651
- usedBytes: z13.number().optional(),
2652
- totalBytes: z13.number().optional(),
2766
+ usedBytes: z14.number().optional(),
2767
+ totalBytes: z14.number().optional(),
2653
2768
  /** With `?live=1`, when the storage answered: what each bucket holds. */
2654
- bucketUsage: z13.array(z13.object({ name: z13.string(), objects: z13.number(), bytes: z13.number() })).optional(),
2655
- host: z13.string(),
2656
- country: z13.string().optional(),
2657
- buckets: z13.number().int(),
2658
- price: z13.object({ perMonth: z13.number(), currency: z13.string() }),
2659
- createdAt: z13.string()
2660
- });
2661
- var BucketSchema = z13.object({
2662
- name: z13.string(),
2663
- owner: z13.string(),
2664
- ownerKind: z13.enum(["user", "org"]),
2665
- endpoint: z13.string().nullable(),
2666
- publicUrl: z13.string().optional(),
2667
- region: z13.string(),
2668
- keys: z13.number().int(),
2669
- objects: z13.number().optional(),
2670
- bytes: z13.number().optional(),
2671
- createdBy: z13.string().nullable(),
2672
- createdAt: z13.string()
2673
- });
2674
- var CreateBucketRequest = z13.object({
2675
- name: z13.string(),
2676
- sizeGib: z13.number().int().optional(),
2677
- near: z13.string().optional(),
2678
- region: z13.string().optional()
2679
- });
2680
- var CreatedBucketSchema = BucketSchema.extend({ storage: ObjectStorageSchema, storageCreated: z13.boolean() });
2769
+ bucketUsage: z14.array(z14.object({ name: z14.string(), objects: z14.number(), bytes: z14.number() })).optional(),
2770
+ host: z14.string(),
2771
+ country: z14.string().optional(),
2772
+ buckets: z14.number().int(),
2773
+ price: z14.object({ perMonth: z14.number(), currency: z14.string() }),
2774
+ createdAt: z14.string()
2775
+ });
2776
+ var BucketSchema = z14.object({
2777
+ name: z14.string(),
2778
+ owner: z14.string(),
2779
+ ownerKind: z14.enum(["user", "org"]),
2780
+ endpoint: z14.string().nullable(),
2781
+ publicUrl: z14.string().optional(),
2782
+ region: z14.string(),
2783
+ keys: z14.number().int(),
2784
+ objects: z14.number().optional(),
2785
+ bytes: z14.number().optional(),
2786
+ createdBy: z14.string().nullable(),
2787
+ createdAt: z14.string()
2788
+ });
2789
+ var CreateBucketRequest = z14.object({
2790
+ name: z14.string(),
2791
+ sizeGib: z14.number().int().optional(),
2792
+ near: z14.string().optional(),
2793
+ region: z14.string().optional()
2794
+ });
2795
+ var CreatedBucketSchema = BucketSchema.extend({ storage: ObjectStorageSchema, storageCreated: z14.boolean() });
2681
2796
  var BucketInfoSchema = BucketSchema.extend({ storage: ObjectStorageSchema });
2682
- var SetBucketPublicRequest = z13.object({ on: z13.boolean(), sub: z13.string().optional() });
2683
- var BucketKeySchema = z13.object({
2684
- id: z13.string(),
2685
- name: z13.string(),
2686
- bucket: z13.string(),
2687
- owner: z13.string(),
2688
- readOnly: z13.boolean(),
2689
- createdBy: z13.string().nullable(),
2690
- createdAt: z13.string()
2691
- });
2692
- var CreateBucketKeyRequest = z13.object({ name: z13.string().optional(), readOnly: z13.boolean().optional() });
2693
- var CreatedBucketKeySchema = BucketKeySchema.extend({ secret: z13.string(), endpoint: z13.string().nullable(), region: z13.string() });
2694
- var GrowStorageRequest = z13.object({ sizeGib: z13.number().int() });
2695
- var StorageBackupSchema = z13.object({
2696
- id: z13.string(),
2697
- owner: z13.string(),
2698
- status: z13.enum(BACKUP_STATUSES),
2797
+ var SetBucketPublicRequest = z14.object({ on: z14.boolean(), sub: z14.string().optional() });
2798
+ var BucketKeySchema = z14.object({
2799
+ id: z14.string(),
2800
+ name: z14.string(),
2801
+ bucket: z14.string(),
2802
+ owner: z14.string(),
2803
+ readOnly: z14.boolean(),
2804
+ createdBy: z14.string().nullable(),
2805
+ createdAt: z14.string()
2806
+ });
2807
+ var CreateBucketKeyRequest = z14.object({ name: z14.string().optional(), readOnly: z14.boolean().optional() });
2808
+ var CreatedBucketKeySchema = BucketKeySchema.extend({ secret: z14.string(), endpoint: z14.string().nullable(), region: z14.string() });
2809
+ var GrowStorageRequest = z14.object({ sizeGib: z14.number().int() });
2810
+ var StorageBackupSchema = z14.object({
2811
+ id: z14.string(),
2812
+ owner: z14.string(),
2813
+ status: z14.enum(BACKUP_STATUSES),
2699
2814
  /** Why it failed; null otherwise. */
2700
- error: z13.string().nullable(),
2815
+ error: z14.string().nullable(),
2701
2816
  /** The storage's volume when taken. */
2702
- diskBytes: z13.number().int().nullable(),
2817
+ diskBytes: z14.number().int().nullable(),
2703
2818
  /** What it holds: the slots that are not all zeros. */
2704
- dataBytes: z13.number().int().nullable(),
2819
+ dataBytes: z14.number().int().nullable(),
2705
2820
  /** What this backup added to the backup store (encrypted, compressed). */
2706
- uploadedBytes: z13.number().int().nullable(),
2821
+ uploadedBytes: z14.number().int().nullable(),
2707
2822
  /** The buckets it holds, and how many access keys they had, as kvbox knew them when it was taken. */
2708
- buckets: z13.array(z13.string()),
2709
- keys: z13.number().int(),
2710
- createdBy: z13.string().nullable(),
2823
+ buckets: z14.array(z14.string()),
2824
+ keys: z14.number().int(),
2825
+ createdBy: z14.string().nullable(),
2711
2826
  /** Taken by the storage's nightly schedule rather than by a person: free, and outside the daily limit. */
2712
- scheduled: z13.boolean().default(false),
2713
- createdAt: z13.string(),
2714
- finishedAt: z13.string().nullable()
2827
+ scheduled: z14.boolean().default(false),
2828
+ createdAt: z14.string(),
2829
+ finishedAt: z14.string().nullable()
2715
2830
  });
2716
- var RestoredKeySchema = z13.object({ bucket: z13.string(), id: z13.string(), name: z13.string() });
2717
- var StorageRestoreSchema = z13.object({
2718
- backup: z13.string(),
2831
+ var RestoredKeySchema = z14.object({ bucket: z14.string(), id: z14.string(), name: z14.string() });
2832
+ var StorageRestoreSchema = z14.object({
2833
+ backup: z14.string(),
2719
2834
  storage: ObjectStorageSchema,
2720
- buckets: z13.object({ kept: z13.array(z13.string()), returned: z13.array(z13.string()), removed: z13.array(z13.string()) }),
2721
- keys: z13.object({ dropped: z13.array(RestoredKeySchema), revoked: z13.array(RestoredKeySchema) }),
2722
- checked: z13.boolean(),
2723
- warnings: z13.array(z13.string())
2835
+ buckets: z14.object({ kept: z14.array(z14.string()), returned: z14.array(z14.string()), removed: z14.array(z14.string()) }),
2836
+ keys: z14.object({ dropped: z14.array(RestoredKeySchema), revoked: z14.array(RestoredKeySchema) }),
2837
+ checked: z14.boolean(),
2838
+ warnings: z14.array(z14.string())
2724
2839
  });
2725
2840
  var OBJECT_LIST_MAX = 1e3;
2726
2841
  var SHARE_LINK_MAX_SEC = 7 * 24 * 3600;
@@ -2730,56 +2845,56 @@ var MULTIPART_PART_BYTES = 16 * 1024 * 1024;
2730
2845
  var UPLOAD_MAX_BYTES = 50 * 1024 * 1024 * 1024;
2731
2846
  var MOVE_MAX_BYTES = 5 * 1024 * 1024 * 1024;
2732
2847
  var DELETE_PREFIXES_MAX = 100;
2733
- var StoredObjectSchema = z13.object({
2734
- key: z13.string(),
2735
- size: z13.number(),
2736
- etag: z13.string(),
2848
+ var StoredObjectSchema = z14.object({
2849
+ key: z14.string(),
2850
+ size: z14.number(),
2851
+ etag: z14.string(),
2737
2852
  /** ISO 8601. */
2738
- modified: z13.string()
2739
- });
2740
- var ObjectListingSchema = z13.object({
2741
- prefix: z13.string(),
2742
- folders: z13.array(z13.string()),
2743
- objects: z13.array(StoredObjectSchema),
2744
- next: z13.string().optional(),
2745
- canWrite: z13.boolean()
2746
- });
2747
- var ObjectInfoSchema = StoredObjectSchema.extend({ contentType: z13.string() });
2748
- var ObjectCountSchema = z13.object({ objects: z13.number(), bytes: z13.number(), more: z13.boolean() });
2749
- var ObjectLinkRequest = z13.object({
2750
- key: z13.string(),
2751
- expiresSec: z13.number().int().positive(),
2853
+ modified: z14.string()
2854
+ });
2855
+ var ObjectListingSchema = z14.object({
2856
+ prefix: z14.string(),
2857
+ folders: z14.array(z14.string()),
2858
+ objects: z14.array(StoredObjectSchema),
2859
+ next: z14.string().optional(),
2860
+ canWrite: z14.boolean()
2861
+ });
2862
+ var ObjectInfoSchema = StoredObjectSchema.extend({ contentType: z14.string() });
2863
+ var ObjectCountSchema = z14.object({ objects: z14.number(), bytes: z14.number(), more: z14.boolean() });
2864
+ var ObjectLinkRequest = z14.object({
2865
+ key: z14.string(),
2866
+ expiresSec: z14.number().int().positive(),
2752
2867
  /** Answer as a download (`Content-Disposition: attachment`) instead of showing it. */
2753
- download: z13.boolean().optional(),
2868
+ download: z14.boolean().optional(),
2754
2869
  /**
2755
2870
  * Let the browser keep what the link answers until the link expires (`Cache-Control: private`, `Expires`),
2756
2871
  * so the same link shown twice is fetched once. Asked again within the hour, for the same file as it
2757
2872
  * is, it is the same URL, and it lasts up to an hour longer than `expiresSec`. For the app's own previews.
2758
2873
  * Only a fetch of the whole file is kept so: the storage answers a part of one (`Range`) without the two headers.
2759
2874
  */
2760
- cached: z13.boolean().optional()
2875
+ cached: z14.boolean().optional()
2761
2876
  });
2762
- var ObjectLinkSchema = z13.object({ url: z13.string(), expiresAt: z13.string() });
2877
+ var ObjectLinkSchema = z14.object({ url: z14.string(), expiresAt: z14.string() });
2763
2878
  var MEDIA_TYPE_RE = /^[\w.+-]+\/[\w.+-]+(?:\s*;[\x20-\x7e]*)?$/;
2764
- var StartUploadRequest = z13.object({ key: z13.string(), size: z13.number().int().nonnegative(), contentType: z13.string().max(200).regex(MEDIA_TYPE_RE, "not a media type like image/png").optional(), overwrite: z13.boolean().optional() });
2765
- var UploadPlanSchema = z13.discriminatedUnion("kind", [
2766
- z13.object({ kind: z13.literal("single"), url: z13.string() }),
2767
- z13.object({ kind: z13.literal("multipart"), uploadId: z13.string(), partSize: z13.number(), urls: z13.array(z13.string()) })
2879
+ var StartUploadRequest = z14.object({ key: z14.string(), size: z14.number().int().nonnegative(), contentType: z14.string().max(200).regex(MEDIA_TYPE_RE, "not a media type like image/png").optional(), overwrite: z14.boolean().optional() });
2880
+ var UploadPlanSchema = z14.discriminatedUnion("kind", [
2881
+ z14.object({ kind: z14.literal("single"), url: z14.string() }),
2882
+ z14.object({ kind: z14.literal("multipart"), uploadId: z14.string(), partSize: z14.number(), urls: z14.array(z14.string()) })
2768
2883
  ]);
2769
- var CompleteUploadRequest = z13.object({
2770
- key: z13.string(),
2771
- uploadId: z13.string(),
2772
- parts: z13.array(z13.object({ part: z13.number().int().positive(), etag: z13.string() })).min(1)
2884
+ var CompleteUploadRequest = z14.object({
2885
+ key: z14.string(),
2886
+ uploadId: z14.string(),
2887
+ parts: z14.array(z14.object({ part: z14.number().int().positive(), etag: z14.string() })).min(1)
2773
2888
  });
2774
- var AbortUploadRequest = z13.object({ key: z13.string(), uploadId: z13.string() });
2775
- var DeleteObjectsRequest = z13.object({ keys: z13.array(z13.string()).max(OBJECT_LIST_MAX).optional(), prefixes: z13.array(z13.string()).max(DELETE_PREFIXES_MAX).optional() });
2776
- var DeletedObjectsSchema = z13.object({
2777
- deleted: z13.number(),
2778
- more: z13.boolean(),
2779
- errors: z13.array(z13.object({ key: z13.string(), message: z13.string() }))
2889
+ var AbortUploadRequest = z14.object({ key: z14.string(), uploadId: z14.string() });
2890
+ var DeleteObjectsRequest = z14.object({ keys: z14.array(z14.string()).max(OBJECT_LIST_MAX).optional(), prefixes: z14.array(z14.string()).max(DELETE_PREFIXES_MAX).optional() });
2891
+ var DeletedObjectsSchema = z14.object({
2892
+ deleted: z14.number(),
2893
+ more: z14.boolean(),
2894
+ errors: z14.array(z14.object({ key: z14.string(), message: z14.string() }))
2780
2895
  });
2781
- var MoveObjectRequest = z13.object({ from: z13.string(), to: z13.string(), overwrite: z13.boolean().optional() });
2782
- var CreateFolderRequest = z13.object({ prefix: z13.string() });
2896
+ var MoveObjectRequest = z14.object({ from: z14.string(), to: z14.string(), overwrite: z14.boolean().optional() });
2897
+ var CreateFolderRequest = z14.object({ prefix: z14.string() });
2783
2898
 
2784
2899
  // src/kvm.ts
2785
2900
  import { accessSync, constants, readFileSync, statSync } from "fs";
@@ -2949,7 +3064,7 @@ var ServerClient = class {
2949
3064
  * `all`: every box on the platform (platform admins only, #78).
2950
3065
  */
2951
3066
  listMachines(opts = {}) {
2952
- return this.call("GET", `/machines${allQuery(opts)}`, z14.array(MachineSchema), void 0, opts.org);
3067
+ return this.call("GET", `/machines${allQuery(opts)}`, z15.array(MachineSchema), void 0, opts.org);
2953
3068
  }
2954
3069
  createMachine(req) {
2955
3070
  return this.call("POST", "/machines", MachineSchema, req, void 0, req.fromBackup !== void 0 ? 2 * 36e5 : void 0);
@@ -2964,6 +3079,10 @@ var ServerClient = class {
2964
3079
  startMachine(name, force = false) {
2965
3080
  return this.call("POST", `/machines/${encodeURIComponent(name)}/start`, MachineSchema, force ? { force } : void 0);
2966
3081
  }
3082
+ /** Stop and boot again in one step (#143): what would refuse the boot refuses before the stop. */
3083
+ restartMachine(name, force = false) {
3084
+ return this.call("POST", `/machines/${encodeURIComponent(name)}/restart`, MachineSchema, force ? { force } : void 0);
3085
+ }
2967
3086
  pauseMachine(name) {
2968
3087
  return this.call("POST", `/machines/${encodeURIComponent(name)}/pause`, MachineSchema);
2969
3088
  }
@@ -3003,10 +3122,10 @@ var ServerClient = class {
3003
3122
  }
3004
3123
  /** Backups, the control plane's only: a box's disk in object storage. Newest first. */
3005
3124
  listBackups() {
3006
- return this.call("GET", "/backups", z14.array(BackupSchema));
3125
+ return this.call("GET", "/backups", z15.array(BackupSchema));
3007
3126
  }
3008
3127
  boxBackups(name) {
3009
- return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z14.array(BackupSchema));
3128
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z15.array(BackupSchema));
3010
3129
  }
3011
3130
  boxBackup(name, id) {
3012
3131
  return this.call("GET", `/machines/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, BackupSchema);
@@ -3028,14 +3147,14 @@ var ServerClient = class {
3028
3147
  * later. Works for a backup whose box, volume or database is gone too.
3029
3148
  */
3030
3149
  removeBackup(id) {
3031
- return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z14.undefined());
3150
+ return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z15.undefined());
3032
3151
  }
3033
3152
  /** A volume's backups (#168): the same as a box's, of the volume's disk. Newest first. */
3034
3153
  listVolumeBackups() {
3035
- return this.call("GET", "/backups?kind=volume", z14.array(VolumeBackupSchema));
3154
+ return this.call("GET", "/backups?kind=volume", z15.array(VolumeBackupSchema));
3036
3155
  }
3037
3156
  volumeBackups(name) {
3038
- return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z14.array(VolumeBackupSchema));
3157
+ return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z15.array(VolumeBackupSchema));
3039
3158
  }
3040
3159
  volumeBackup(name, id) {
3041
3160
  return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, VolumeBackupSchema);
@@ -3061,7 +3180,7 @@ var ServerClient = class {
3061
3180
  }
3062
3181
  /** Wake hooks (#101), the control plane's only: a URL and a secret that wake the box. */
3063
3182
  boxHooks(name) {
3064
- return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z14.array(WakeHookSchema));
3183
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z15.array(WakeHookSchema));
3065
3184
  }
3066
3185
  createBoxHook(name) {
3067
3186
  return this.call("POST", `/machines/${encodeURIComponent(name)}/hooks`, CreatedWakeHookSchema);
@@ -3089,7 +3208,7 @@ var ServerClient = class {
3089
3208
  }
3090
3209
  /** Every readable box's subdomains, one entry each. */
3091
3210
  listSubdomains() {
3092
- return this.call("GET", "/subdomains", z14.array(SubdomainSchema));
3211
+ return this.call("GET", "/subdomains", z15.array(SubdomainSchema));
3093
3212
  }
3094
3213
  /** Custom domains (#89), the control plane's only: serve the box at the user's own name. */
3095
3214
  addDomain(name, req) {
@@ -3100,7 +3219,7 @@ var ServerClient = class {
3100
3219
  }
3101
3220
  /** Every readable box's custom domains. */
3102
3221
  listDomains() {
3103
- return this.call("GET", "/domains", z14.array(DomainSchema));
3222
+ return this.call("GET", "/domains", z15.array(DomainSchema));
3104
3223
  }
3105
3224
  /** A running box's own load, memory and disk, asked of its guest (#67). */
3106
3225
  machineStats(name) {
@@ -3115,6 +3234,10 @@ var ServerClient = class {
3115
3234
  machineTraffic(name, query) {
3116
3235
  return this.call("GET", `/machines/${encodeURIComponent(name)}/traffic${query}`, TrafficReportSchema);
3117
3236
  }
3237
+ /** A box's CPU, memory, disk and network over time (observability layer 2); a control plane only. `query`: "" or "?since=…". */
3238
+ machineResources(name, query) {
3239
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/resources${query}`, ResourceReportSchema);
3240
+ }
3118
3241
  /** Every box of the caller over the window (#41 on a host, #42 through a control plane); dates as the user wrote them. */
3119
3242
  usageReport(since, until2, all = false) {
3120
3243
  const q = new URLSearchParams();
@@ -3137,22 +3260,22 @@ var ServerClient = class {
3137
3260
  return this.call("POST", "/billing/redeem", RedeemResponseSchema, { code });
3138
3261
  }
3139
3262
  deleteMachine(name) {
3140
- return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z14.undefined());
3263
+ return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z15.undefined());
3141
3264
  }
3142
3265
  /** Like `listMachines`, for snapshots. */
3143
3266
  listSnapshots(opts = {}) {
3144
- return this.call("GET", `/snapshots${allQuery(opts)}`, z14.array(SnapshotSchema), void 0, opts.org);
3267
+ return this.call("GET", `/snapshots${allQuery(opts)}`, z15.array(SnapshotSchema), void 0, opts.org);
3145
3268
  }
3146
3269
  createSnapshot(req) {
3147
3270
  return this.call("POST", "/snapshots", SnapshotSchema, req);
3148
3271
  }
3149
3272
  deleteSnapshot(name) {
3150
- return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z14.undefined());
3273
+ return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z15.undefined());
3151
3274
  }
3152
3275
  // ---- environment variables (#88), a control plane only: the caller's slug, or `--org`'s ----
3153
3276
  /** `org`: that org's list instead of `--org`'s (or the caller's own). */
3154
3277
  listEnv(org) {
3155
- return this.call("GET", "/vars", z14.array(EnvVarSchema), void 0, org);
3278
+ return this.call("GET", "/vars", z15.array(EnvVarSchema), void 0, org);
3156
3279
  }
3157
3280
  setEnv(name, req) {
3158
3281
  return this.call("PUT", `/vars/${encodeURIComponent(name)}`, EnvChangeSchema, req);
@@ -3172,13 +3295,13 @@ var ServerClient = class {
3172
3295
  }
3173
3296
  // ---- volumes (#52) ----
3174
3297
  listVolumes(opts = {}) {
3175
- return this.call("GET", `/volumes${allQuery(opts)}`, z14.array(VolumeSchema), void 0, opts.org);
3298
+ return this.call("GET", `/volumes${allQuery(opts)}`, z15.array(VolumeSchema), void 0, opts.org);
3176
3299
  }
3177
3300
  createVolume(req) {
3178
3301
  return this.call("POST", "/volumes", VolumeSchema, req);
3179
3302
  }
3180
3303
  deleteVolume(name) {
3181
- return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z14.undefined());
3304
+ return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z15.undefined());
3182
3305
  }
3183
3306
  /** Both answer with the box as it is afterwards (restarted when it was running). */
3184
3307
  attachVolume(name, req) {
@@ -3193,7 +3316,7 @@ var ServerClient = class {
3193
3316
  }
3194
3317
  // ---- cron service (#190): the control plane's alone ----
3195
3318
  listCronServices(opts = {}) {
3196
- return this.call("GET", `/cron${allQuery(opts)}`, z14.array(CronServiceSchema), void 0, opts.org);
3319
+ return this.call("GET", `/cron${allQuery(opts)}`, z15.array(CronServiceSchema), void 0, opts.org);
3197
3320
  }
3198
3321
  createCronService(name) {
3199
3322
  return this.call("POST", "/cron", CronServiceSchema, { name });
@@ -3202,10 +3325,10 @@ var ServerClient = class {
3202
3325
  return this.call("GET", `/cron/${encodeURIComponent(name)}`, CronServiceSchema);
3203
3326
  }
3204
3327
  deleteCronService(name) {
3205
- return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z14.undefined());
3328
+ return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z15.undefined());
3206
3329
  }
3207
3330
  listCronTriggers(service) {
3208
- return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z14.array(CronTriggerSchema));
3331
+ return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z15.array(CronTriggerSchema));
3209
3332
  }
3210
3333
  addCronTrigger(service, req) {
3211
3334
  return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers`, CronTriggerSchema, req);
@@ -3215,18 +3338,18 @@ var ServerClient = class {
3215
3338
  return this.call("PATCH", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, CronTriggerSchema, { enabled: enabled2 });
3216
3339
  }
3217
3340
  deleteCronTrigger(service, id) {
3218
- return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, z14.undefined());
3341
+ return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, z15.undefined());
3219
3342
  }
3220
3343
  /** Marks it due: kvbox-cron fires it within a few seconds. */
3221
3344
  runCronTrigger(service, id) {
3222
3345
  return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/run`, CronTriggerSchema);
3223
3346
  }
3224
3347
  listCronRuns(service, id, limit) {
3225
- return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`, z14.array(CronRunSchema));
3348
+ return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`, z15.array(CronRunSchema));
3226
3349
  }
3227
3350
  // ---- object storage (#182): the control plane's alone ----
3228
3351
  listBuckets(opts = {}) {
3229
- return this.call("GET", `/buckets${allQuery(opts)}`, z14.array(BucketSchema), void 0, opts.org);
3352
+ return this.call("GET", `/buckets${allQuery(opts)}`, z15.array(BucketSchema), void 0, opts.org);
3230
3353
  }
3231
3354
  /** The first bucket of a slug also makes its storage: a box boots twice, so this may take a couple of minutes. */
3232
3355
  createBucket(req) {
@@ -3240,26 +3363,26 @@ var ServerClient = class {
3240
3363
  return this.call("PUT", `/buckets/${encodeURIComponent(name)}/public`, BucketSchema, req);
3241
3364
  }
3242
3365
  deleteBucket(name, force = false) {
3243
- return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`, z14.undefined());
3366
+ return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`, z15.undefined());
3244
3367
  }
3245
3368
  listBucketKeys(name) {
3246
- return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z14.array(BucketKeySchema));
3369
+ return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z15.array(BucketKeySchema));
3247
3370
  }
3248
3371
  createBucketKey(name, req) {
3249
3372
  return this.call("POST", `/buckets/${encodeURIComponent(name)}/keys`, CreatedBucketKeySchema, req);
3250
3373
  }
3251
3374
  deleteBucketKey(name, id) {
3252
- return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`, z14.undefined());
3375
+ return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`, z15.undefined());
3253
3376
  }
3254
3377
  listStorage(opts = {}) {
3255
- return this.call("GET", `/storage${allQuery(opts)}`, z14.array(ObjectStorageSchema), void 0, opts.org);
3378
+ return this.call("GET", `/storage${allQuery(opts)}`, z15.array(ObjectStorageSchema), void 0, opts.org);
3256
3379
  }
3257
3380
  growStorage(sizeGib) {
3258
3381
  return this.call("POST", "/storage/grow", ObjectStorageSchema, { sizeGib });
3259
3382
  }
3260
3383
  /** Backups of the slug's whole object storage (#186 slice 3), newest first. */
3261
3384
  storageBackups() {
3262
- return this.call("GET", "/storage/backups", z14.array(StorageBackupSchema));
3385
+ return this.call("GET", "/storage/backups", z15.array(StorageBackupSchema));
3263
3386
  }
3264
3387
  storageBackup(id) {
3265
3388
  return this.call("GET", `/storage/backups/${encodeURIComponent(id)}`, StorageBackupSchema);
@@ -3287,11 +3410,11 @@ var ServerClient = class {
3287
3410
  return `/managed/${encodeURIComponent(kind)}${name === void 0 ? "" : `/${encodeURIComponent(name)}`}${rest}`;
3288
3411
  }
3289
3412
  managedCatalog() {
3290
- return this.call("GET", "/managed/catalog", z14.array(ManagedCatalogEntrySchema));
3413
+ return this.call("GET", "/managed/catalog", z15.array(ManagedCatalogEntrySchema));
3291
3414
  }
3292
3415
  /** One kind's services, or every kind's when `kind` is left out. */
3293
3416
  listManaged(kind, opts = {}) {
3294
- return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`, z14.array(ManagedSchema), void 0, opts.org);
3417
+ return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`, z15.array(ManagedSchema), void 0, opts.org);
3295
3418
  }
3296
3419
  /** From a backup (`fromBackup`) it waits for the restore too: the control plane gives its host 2 h for the download. */
3297
3420
  createManaged(kind, req) {
@@ -3302,7 +3425,7 @@ var ServerClient = class {
3302
3425
  return this.call("GET", this.managedPath(kind, name), ManagedSchema);
3303
3426
  }
3304
3427
  deleteManaged(kind, name) {
3305
- return this.call("DELETE", this.managedPath(kind, name), z14.undefined());
3428
+ return this.call("DELETE", this.managedPath(kind, name), z15.undefined());
3306
3429
  }
3307
3430
  managedPassword(kind, name) {
3308
3431
  return this.call("GET", this.managedPath(kind, name, "/password"), ManagedSecretSchema);
@@ -3324,10 +3447,10 @@ var ServerClient = class {
3324
3447
  }
3325
3448
  /** A managed service's backups (#186): its storage's, by the volume backup engine. Every one of a kind, those of removed services too. */
3326
3449
  listManagedBackups(kind) {
3327
- return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z14.array(ManagedBackupSchema));
3450
+ return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z15.array(ManagedBackupSchema));
3328
3451
  }
3329
3452
  managedBackups(kind, name) {
3330
- return this.call("GET", this.managedPath(kind, name, "/backups"), z14.array(ManagedBackupSchema));
3453
+ return this.call("GET", this.managedPath(kind, name, "/backups"), z15.array(ManagedBackupSchema));
3331
3454
  }
3332
3455
  managedBackup(kind, name, id) {
3333
3456
  return this.call("GET", this.managedPath(kind, name, `/backups/${encodeURIComponent(id)}`), ManagedBackupSchema);
@@ -3369,7 +3492,7 @@ var ServerClient = class {
3369
3492
  return this.call("POST", "/login/device/token", DeviceLoginPollSchema, { deviceCode });
3370
3493
  }
3371
3494
  logout() {
3372
- return this.call("POST", "/logout", z14.unknown()).then(() => void 0);
3495
+ return this.call("POST", "/logout", z15.unknown()).then(() => void 0);
3373
3496
  }
3374
3497
  me() {
3375
3498
  return this.call("GET", "/me", MeResponseSchema);
@@ -3380,25 +3503,25 @@ var ServerClient = class {
3380
3503
  * credential. Null: each readable slug whatever `--org` says, which is how the caller's own slug is read.
3381
3504
  */
3382
3505
  listIntegrations(org) {
3383
- return this.call("GET", "/integrations", z14.array(IntegrationSchema), void 0, org);
3506
+ return this.call("GET", "/integrations", z15.array(IntegrationSchema), void 0, org);
3384
3507
  }
3385
3508
  /** What can be connected on this control plane, and by which kind of slug. */
3386
3509
  integrationCatalog() {
3387
- return this.call("GET", "/integrations/catalog", z14.array(IntegrationCatalogEntrySchema), void 0, null);
3510
+ return this.call("GET", "/integrations/catalog", z15.array(IntegrationCatalogEntrySchema), void 0, null);
3388
3511
  }
3389
3512
  // ---- API keys (`kvbox key …`, #189) ----
3390
3513
  listApiKeys() {
3391
- return this.call("GET", "/keys", z14.array(ApiKeySchema));
3514
+ return this.call("GET", "/keys", z15.array(ApiKeySchema));
3392
3515
  }
3393
3516
  createApiKey(req) {
3394
3517
  return this.call("POST", "/keys", CreatedApiKeySchema, req);
3395
3518
  }
3396
3519
  deleteApiKey(name) {
3397
- return this.call("DELETE", `/keys/${encodeURIComponent(name)}`, z14.unknown()).then(() => void 0);
3520
+ return this.call("DELETE", `/keys/${encodeURIComponent(name)}`, z15.unknown()).then(() => void 0);
3398
3521
  }
3399
3522
  // ---- orgs (`kvbox org …`) ----
3400
3523
  listOrgs() {
3401
- return this.call("GET", "/orgs", z14.array(OrgMembershipSchema));
3524
+ return this.call("GET", "/orgs", z15.array(OrgMembershipSchema));
3402
3525
  }
3403
3526
  createOrg(req) {
3404
3527
  return this.call("POST", "/orgs", CloudOrgSchema, req);
@@ -3407,16 +3530,16 @@ var ServerClient = class {
3407
3530
  return this.call("GET", `/orgs/${encodeURIComponent(slug)}`, OrgDetailSchema);
3408
3531
  }
3409
3532
  deleteOrg(slug) {
3410
- return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z14.undefined());
3533
+ return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z15.undefined());
3411
3534
  }
3412
3535
  addMember(slug, req) {
3413
- return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z14.undefined(), req);
3536
+ return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z15.undefined(), req);
3414
3537
  }
3415
3538
  setRole(slug, username, role) {
3416
- return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z14.unknown(), { role }).then(() => void 0);
3539
+ return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z15.unknown(), { role }).then(() => void 0);
3417
3540
  }
3418
3541
  removeMember(slug, username) {
3419
- return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z14.undefined());
3542
+ return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z15.undefined());
3420
3543
  }
3421
3544
  /** Sign this machine's key again (#51); the key must be one the user logged in with. */
3422
3545
  sshCert(req) {
@@ -4376,6 +4499,7 @@ function getRows(box2, subs, user) {
4376
4499
  const update = box2.latestBase === void 0 ? "" : ` ${color.yellow(`(${box2.latestBase} available: ${box2.status === "hibernated" ? `kvbox wake ${displayName(box2, user)}, then ` : ""}kvbox vm update ${displayName(box2, user)})`)}`;
4377
4500
  rows2.push(["base", `${box2.image === void 0 ? box2.base : `${box2.image} ${box2.base}`}${update}`]);
4378
4501
  rows2.push(["created", `${age(box2.createdAt)} ${color.dim(`(${box2.createdAt})`)}`]);
4502
+ if (box2.bootedAt !== void 0) rows2.push(["booted", `${age(box2.bootedAt)} ${color.dim(`(${box2.bootedAt})`)}`]);
4379
4503
  return rows2;
4380
4504
  }
4381
4505
 
@@ -5160,19 +5284,136 @@ function parseCount(text2) {
5160
5284
  return n2;
5161
5285
  }
5162
5286
  function parseSize(flag, text2) {
5163
- const mib = parseMib(text2);
5164
- if (mib === void 0) throw new KvboxError(`${flag} ${text2}: give a size like 16GB or 4096MB`);
5165
- return mib;
5287
+ const mib2 = parseMib(text2);
5288
+ if (mib2 === void 0) throw new KvboxError(`${flag} ${text2}: give a size like 16GB or 4096MB`);
5289
+ return mib2;
5166
5290
  }
5167
5291
  function parseGib(flag, text2) {
5168
- const mib = parseSize(flag, text2);
5169
- if (mib % 1024 !== 0) throw new KvboxError(`${flag} ${text2}: disk sizes are whole GB`);
5170
- return mib / 1024;
5292
+ const mib2 = parseSize(flag, text2);
5293
+ if (mib2 % 1024 !== 0) throw new KvboxError(`${flag} ${text2}: disk sizes are whole GB`);
5294
+ return mib2 / 1024;
5171
5295
  }
5172
5296
 
5173
- // src/commands/vm/resume.ts
5297
+ // src/commands/vm/resources.ts
5298
+ import { Command as Command33 } from "commander";
5299
+
5300
+ // src/commands/vm/traffic.ts
5174
5301
  import { Command as Command32 } from "commander";
5175
- var resumeCommand = new Command32("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) => {
5302
+ var trafficCommand = new Command32("traffic").description(`requests, errors, latency, bytes and wakes through a box's HTTPS names (last ${TRAFFIC_KEEP_DAYS} days at most)`).argument("<name>", "box name").option("--since <when>", "how far back: 1h, 24h, 7d, or a date like 2026-11-19 (default 24h)").option("--host <name>", "one of the box's names only, e.g. web.kvbox.app").option("--json", "print as JSON").action(async (name, opts, cmd) => {
5303
+ const q = new URLSearchParams();
5304
+ if (opts.since !== void 0) q.set("since", sinceOf(opts.since));
5305
+ if (opts.host !== void 0) q.set("host", opts.host);
5306
+ const client = await clientFor(cmd.optsWithGlobals());
5307
+ try {
5308
+ if (client.target.kind !== "cloud") throw new KvboxError("traffic is counted by the kvbox cloud's edge: kvbox login first");
5309
+ const report = await client.machineTraffic(name, q.size === 0 ? "" : `?${q.toString()}`);
5310
+ if (opts.json) json(report);
5311
+ else if (report.totals.requests === 0) info(`no requests reached ${name} through its HTTPS names since ${when(report.since)}`);
5312
+ else process.stdout.write(block2(report));
5313
+ } finally {
5314
+ await client.close();
5315
+ }
5316
+ });
5317
+ var UNITS = { m: 6e4, h: 36e5, d: 864e5 };
5318
+ function sinceOf(text2, now = Date.now()) {
5319
+ const span = /^(\d+)([mhd])$/.exec(text2.trim());
5320
+ if (span) return new Date(now - Number(span[1]) * UNITS[span[2]]).toISOString();
5321
+ const t = Date.parse(text2);
5322
+ if (Number.isNaN(t)) throw new KvboxError(`--since ${text2}: write a span like 1h, 24h or 7d, or a date like 2026-11-19`);
5323
+ return new Date(t).toISOString();
5324
+ }
5325
+ var when = (iso2) => `${iso2.slice(0, 16).replace("T", " ")} UTC`;
5326
+ var n = (v) => v.toLocaleString("en-US");
5327
+ function bytes(v) {
5328
+ if (v < 1e3) return `${v} B`;
5329
+ const units = ["kB", "MB", "GB", "TB"];
5330
+ let x = v;
5331
+ let u = -1;
5332
+ while (x >= 1e3 && u < units.length - 1) {
5333
+ x /= 1e3;
5334
+ u++;
5335
+ }
5336
+ return `${x < 10 ? x.toFixed(1) : Math.round(x)} ${units[u]}`;
5337
+ }
5338
+ var ms = (v) => v === null ? "-" : v >= 1e3 ? `${v / 1e3} s` : `${v} ms`;
5339
+ var share = (part, whole2) => whole2 === 0 || part === 0 ? "" : color.dim(` (${(part / whole2 * 100).toFixed(part === whole2 ? 0 : 1)}%)`);
5340
+ function block2(r) {
5341
+ const t = r.totals;
5342
+ const rows2 = [
5343
+ ["name", boxName(r.box)],
5344
+ ["window", `${when(r.since)} to ${when(r.until)}`],
5345
+ ["hosts", r.host ?? (r.hosts.join(", ") || "-")],
5346
+ ["requests", n(t.requests)],
5347
+ ["2xx", n(t.s2xx) + share(t.s2xx, t.requests)],
5348
+ ["3xx", n(t.s3xx) + share(t.s3xx, t.requests)],
5349
+ ["4xx", n(t.s4xx) + share(t.s4xx, t.requests)],
5350
+ ["5xx", (t.s5xx > 0 ? color.red(n(t.s5xx)) : "0") + share(t.s5xx, t.requests)],
5351
+ ["latency", `p50 \u2264 ${ms(t.p50Ms)}, p95 \u2264 ${ms(t.p95Ms)}`],
5352
+ ["bytes in", bytes(t.bytesIn)],
5353
+ ["bytes out", bytes(t.bytesOut)],
5354
+ ["wakes", t.wakes === 0 ? "0" : `${n(t.wakes)}, waited ${ms(t.wakeWaitMs)} on average`]
5355
+ ];
5356
+ const width2 = Math.max(...rows2.map(([k]) => k.length));
5357
+ const lines = rows2.map(([k, v]) => `${color.dim(k.padStart(width2))} ${v}`);
5358
+ lines.push(color.dim("published ports and SSH do not pass the edge and are not counted"));
5359
+ return `${lines.join("\n")}
5360
+ `;
5361
+ }
5362
+
5363
+ // src/commands/vm/resources.ts
5364
+ var resourcesCommand = new Command33("resources").description(`CPU, memory, disk and network of a box over time, measured while it runs (last ${RESOURCE_KEEP_DAYS} days at most)`).argument("<name>", "box name").option("--since <when>", "how far back: 1h, 24h, 7d, or a date like 2026-11-19 (default 24h)").option("--json", "print as JSON").action(async (name, opts, cmd) => {
5365
+ const query = opts.since === void 0 ? "" : `?since=${encodeURIComponent(sinceOf(opts.since))}`;
5366
+ const client = await clientFor(cmd.optsWithGlobals());
5367
+ try {
5368
+ if (client.target.kind !== "cloud") throw new KvboxError("resources over time are kept by the kvbox cloud: kvbox login first (kvbox vm top shows a box right now)");
5369
+ const report = await client.machineResources(name, query);
5370
+ if (opts.json) json(report);
5371
+ else if (report.points.length === 0) info(`nothing was measured of ${name} since ${when2(report.since)}: a box is measured only while it runs, and the first figures take a few minutes`);
5372
+ else process.stdout.write(block3(report));
5373
+ } finally {
5374
+ await client.close();
5375
+ }
5376
+ });
5377
+ var when2 = (iso2) => `${iso2.slice(0, 16).replace("T", " ")} UTC`;
5378
+ var pct2 = (v) => v === null ? "-" : `${v}%`;
5379
+ var mib = (v) => gb(v * 1024 ** 2);
5380
+ function block3(r) {
5381
+ const t = r.totals;
5382
+ const of = (total) => total === null ? "" : color.dim(` of ${total}`);
5383
+ const rows2 = [
5384
+ ["name", boxName(r.box)],
5385
+ ["window", `${when2(r.since)} to ${when2(r.until)}`],
5386
+ ["cpu", `${pct2(t.cpuPct)} average, ${pct2(t.cpuMaxPct)} busiest minute${r.vcpu === null ? "" : color.dim(` of ${r.vcpu} vCPU`)}`],
5387
+ ["memory", t.memUsedMib === null ? "-" : `${mib(t.memUsedMib)} average, ${mib(t.memMaxMib ?? t.memUsedMib)} highest${of(t.memTotalMib === null ? null : mib(t.memTotalMib))}`],
5388
+ // A disk in the units its size was asked in (`--disk 8GB`); the network rows are transfer, in decimal units like traffic.
5389
+ ["disk", t.diskUsedBytes === null ? "-" : `${gb(t.diskUsedBytes)}${of(t.diskTotalBytes === null ? null : gb(t.diskTotalBytes))}`],
5390
+ ["network in", bytes(t.netInBytes)],
5391
+ ["network out", bytes(t.netOutBytes)]
5392
+ ];
5393
+ const width2 = Math.max(...rows2.map(([k]) => k.length));
5394
+ const lines = rows2.map(([k, v]) => `${color.dim(k.padStart(width2))} ${v}`);
5395
+ if (t.memUsedMib === null) lines.push(color.dim("memory and disk come from inside the box: none means it did not answer (kvbox vm update moves an old box onto the current image)"));
5396
+ lines.push(color.dim("measured only while the box runs; network is everything on the box's interface, SSH and published ports included"));
5397
+ return `${lines.join("\n")}
5398
+ `;
5399
+ }
5400
+
5401
+ // src/commands/vm/restart.ts
5402
+ import { Command as Command34 } from "commander";
5403
+ var restartCommand = new Command34("restart").description("stop a box and boot it again in one step (a hibernated box loses its saved memory)").argument("<name>", "box name").option("--force", "skip the capacity guard").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
5404
+ const client = await clientFor(cmd.optsWithGlobals());
5405
+ try {
5406
+ const box2 = await spin(`restarting ${name}\u2026`, client.restartMachine(name, opts.force ?? false));
5407
+ if (opts.json) json(box2);
5408
+ else info(`${color.green("\u2713")} ${describe(box2)}`);
5409
+ } finally {
5410
+ await client.close();
5411
+ }
5412
+ });
5413
+
5414
+ // src/commands/vm/resume.ts
5415
+ import { Command as Command35 } from "commander";
5416
+ var resumeCommand = new Command35("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) => {
5176
5417
  const client = await clientFor(cmd.optsWithGlobals());
5177
5418
  try {
5178
5419
  const box2 = await spin(`resuming ${name}\u2026`, client.resumeMachine(name));
@@ -5184,8 +5425,8 @@ var resumeCommand = new Command32("resume").description("continue a box that is
5184
5425
  });
5185
5426
 
5186
5427
  // src/commands/vm/rm.ts
5187
- import { Command as Command33 } from "commander";
5188
- var rmCommand4 = new Command33("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) => {
5428
+ import { Command as Command36 } from "commander";
5429
+ var rmCommand4 = new Command36("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) => {
5189
5430
  const client = await clientFor(cmd.optsWithGlobals());
5190
5431
  try {
5191
5432
  const box2 = pickRef(await boxesFor(client, name), name, me(client));
@@ -5205,7 +5446,7 @@ var rmCommand4 = new Command33("rm").description("destroy a box (its disk is del
5205
5446
  });
5206
5447
 
5207
5448
  // src/commands/vm/set.ts
5208
- import { Command as Command34 } from "commander";
5449
+ import { Command as Command37 } from "commander";
5209
5450
 
5210
5451
  // src/swap.ts
5211
5452
  import { spawn as spawn4 } from "child_process";
@@ -5215,9 +5456,9 @@ var SWAP_MIN_MIB = 256;
5215
5456
  function parseSwap(text2) {
5216
5457
  const t = text2.trim().toLowerCase();
5217
5458
  if (t === "off" || t === "none" || t === "0") return 0;
5218
- const mib = parseMib(t);
5219
- if (mib === void 0 || mib < SWAP_MIN_MIB) throw new KvboxError(`--swap ${text2}: give a size of at least ${SWAP_MIN_MIB}M (2G, 512M), or off`);
5220
- return mib;
5459
+ const mib2 = parseMib(t);
5460
+ if (mib2 === void 0 || mib2 < SWAP_MIN_MIB) throw new KvboxError(`--swap ${text2}: give a size of at least ${SWAP_MIN_MIB}M (2G, 512M), or off`);
5461
+ return mib2;
5221
5462
  }
5222
5463
  function swapScript() {
5223
5464
  return [
@@ -5261,16 +5502,16 @@ function swapScript() {
5261
5502
  'echo "kvbox-swap ${3:-0} ${4:-0} $(cat "$zs" 2>/dev/null || echo N)"'
5262
5503
  ].join("\n");
5263
5504
  }
5264
- function swapCommand(mib) {
5265
- return `sudo -n sh -c ${shellQuote(swapScript())} kvbox-swap ${mib}`;
5505
+ function swapCommand(mib2) {
5506
+ return `sudo -n sh -c ${shellQuote(swapScript())} kvbox-swap ${mib2}`;
5266
5507
  }
5267
5508
  function parseSwapReport(output) {
5268
5509
  const m = /^kvbox-swap (\d+) (\d+) (\S+)\s*$/m.exec(output);
5269
5510
  if (!m) return void 0;
5270
5511
  return { sizeMib: Math.round(Number(m[1]) / 1024), usedMib: Math.round(Number(m[2]) / 1024), zswap: m[3] === "Y" || m[3] === "1" };
5271
5512
  }
5272
- function runSwap(ep, mib) {
5273
- const child = spawn4("ssh", ["-n", ...sshArgs(ep), swapCommand(mib)], { stdio: ["ignore", "pipe", "pipe"] });
5513
+ function runSwap(ep, mib2) {
5514
+ const child = spawn4("ssh", ["-n", ...sshArgs(ep), swapCommand(mib2)], { stdio: ["ignore", "pipe", "pipe"] });
5274
5515
  const chunks = [];
5275
5516
  child.stdout.on("data", (c2) => chunks.push(c2));
5276
5517
  child.stderr.on("data", (c2) => chunks.push(c2));
@@ -5281,7 +5522,7 @@ function runSwap(ep, mib) {
5281
5522
  }
5282
5523
 
5283
5524
  // src/commands/vm/set.ts
5284
- var setCommand = new Command34("set").description("change a box's settings, e.g. --auto-hibernate 30m (off: never), --idle-check /home/kvbox/idle.sh, --integration github, --swap 2G").argument("<name>", "box name").option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never)").option("--idle-check <script>", "a script in the box that exits 0 when it is idle, asked instead of network traffic (off: none)").option("--integration <list>", "the integrations turned on for the box, replacing its list, e.g. github,claude (off: none)").option("--swap <size>", "a swap file on the box's disk for memory spikes such as a build (2G, 512M; off: none)").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
5525
+ var setCommand = new Command37("set").description("change a box's settings, e.g. --auto-hibernate 30m (off: never), --idle-check /home/kvbox/idle.sh, --integration github, --swap 2G").argument("<name>", "box name").option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never)").option("--idle-check <script>", "a script in the box that exits 0 when it is idle, asked instead of network traffic (off: none)").option("--integration <list>", "the integrations turned on for the box, replacing its list, e.g. github,claude (off: none)").option("--swap <size>", "a swap file on the box's disk for memory spikes such as a build (2G, 512M; off: none)").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
5285
5526
  if (opts.autoHibernate === void 0 && opts.idleCheck === void 0 && opts.integration === void 0 && opts.swap === void 0) {
5286
5527
  throw new KvboxError("nothing to change: give --auto-hibernate, --idle-check, --integration or --swap");
5287
5528
  }
@@ -5322,17 +5563,17 @@ var setCommand = new Command34("set").description("change a box's settings, e.g.
5322
5563
  await client.close();
5323
5564
  }
5324
5565
  });
5325
- async function setSwap(client, found, name, mib, cmd) {
5566
+ async function setSwap(client, found, name, mib2, cmd) {
5326
5567
  const cert = await ensureCert(client, void 0, void 0, { owner: found.owner });
5327
5568
  const wasRunning = found.status === "running";
5328
5569
  const box2 = wasRunning ? found : await wakeUp(client, found, displayName(found, me(client)));
5329
5570
  const ep = sshEndpoint(box2, client.target);
5330
5571
  if (!wasRunning) await spin(`waiting for ${name} to accept SSH\u2026`, waitForSsh(ep));
5331
- const what = mib === 0 ? `removing ${name}'s swap\u2026` : `setting up ${mib >= 1024 ? `${mib / 1024}G` : `${mib}M`} of swap in ${name}\u2026`;
5332
- let result = await spin(what, runSwap(ep, mib));
5572
+ const what = mib2 === 0 ? `removing ${name}'s swap\u2026` : `setting up ${mib2 >= 1024 ? `${mib2 / 1024}G` : `${mib2}M`} of swap in ${name}\u2026`;
5573
+ let result = await spin(what, runSwap(ep, mib2));
5333
5574
  if (result.status === 255) {
5334
5575
  const again = await clientFor(cmd.optsWithGlobals());
5335
- if (await renewAfterRefusal(again, cert, found.owner).finally(() => again.close())) result = await spin(what, runSwap(ep, mib));
5576
+ if (await renewAfterRefusal(again, cert, found.owner).finally(() => again.close())) result = await spin(what, runSwap(ep, mib2));
5336
5577
  }
5337
5578
  const report = parseSwapReport(result.output);
5338
5579
  if (result.status !== 0 || !report) {
@@ -5359,8 +5600,8 @@ function parseIdleCheck(text2) {
5359
5600
  }
5360
5601
 
5361
5602
  // src/commands/vm/start.ts
5362
- import { Command as Command35 } from "commander";
5363
- var startCommand = new Command35("start").description("boot a stopped box again (same name, IP and disk)").argument("<name>", "box name").option("--force", "skip the capacity guard").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
5603
+ import { Command as Command38 } from "commander";
5604
+ var startCommand = new Command38("start").description("boot a stopped box again (same name, IP and disk)").argument("<name>", "box name").option("--force", "skip the capacity guard").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
5364
5605
  const client = await clientFor(cmd.optsWithGlobals());
5365
5606
  try {
5366
5607
  const box2 = await spin(`booting ${name}\u2026`, client.startMachine(name, opts.force ?? false));
@@ -5372,8 +5613,8 @@ var startCommand = new Command35("start").description("boot a stopped box again
5372
5613
  });
5373
5614
 
5374
5615
  // src/commands/vm/stop.ts
5375
- import { Command as Command36 } from "commander";
5376
- var stopCommand = new Command36("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) => {
5616
+ import { Command as Command39 } from "commander";
5617
+ var stopCommand = new Command39("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) => {
5377
5618
  const client = await clientFor(cmd.optsWithGlobals());
5378
5619
  try {
5379
5620
  const box2 = await spin(`shutting ${name} down\u2026`, client.stopMachine(name));
@@ -5385,8 +5626,8 @@ var stopCommand = new Command36("stop").description("shut a box down (its disk i
5385
5626
  });
5386
5627
 
5387
5628
  // src/commands/vm/top.ts
5388
- import { Command as Command37 } from "commander";
5389
- var topCommand = new Command37("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) => {
5629
+ import { Command as Command40 } from "commander";
5630
+ var topCommand = new Command40("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) => {
5390
5631
  const client = await clientFor(cmd.optsWithGlobals());
5391
5632
  try {
5392
5633
  const running = (await client.listMachines({ all: opts.all })).filter((b) => b.status === "running");
@@ -5429,7 +5670,7 @@ async function mapLimit(items, limit, fn) {
5429
5670
  await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
5430
5671
  return out;
5431
5672
  }
5432
- var pct = (used, total) => total > 0 ? color.dim(` ${Math.round(used / total * 100)}%`) : "";
5673
+ var pct3 = (used, total) => total > 0 ? color.dim(` ${Math.round(used / total * 100)}%`) : "";
5433
5674
  function topRows(entries, cloud) {
5434
5675
  return entries.map((e) => {
5435
5676
  const s = e.stats;
@@ -5437,80 +5678,17 @@ function topRows(entries, cloud) {
5437
5678
  ...cloud ? { owner: ownerCell(e, cloud.me) } : {},
5438
5679
  name: boxName(e.name),
5439
5680
  load: s ? `${s.load[0].toFixed(2)} ${s.load[1].toFixed(2)} ${color.dim(`/${s.cpus}`)}` : "-",
5440
- mem: s ? `${gbShort(s.memUsedMib * 1024 ** 2)}/${gbShort(s.memTotalMib * 1024 ** 2)}${pct(s.memUsedMib, s.memTotalMib)}` : "-",
5441
- disk: s ? `${gbShort(s.diskUsedBytes)}/${gbShort(s.diskTotalBytes)}${pct(s.diskUsedBytes, s.diskTotalBytes)}` : "-",
5681
+ mem: s ? `${gbShort(s.memUsedMib * 1024 ** 2)}/${gbShort(s.memTotalMib * 1024 ** 2)}${pct3(s.memUsedMib, s.memTotalMib)}` : "-",
5682
+ disk: s ? `${gbShort(s.diskUsedBytes)}/${gbShort(s.diskTotalBytes)}${pct3(s.diskUsedBytes, s.diskTotalBytes)}` : "-",
5442
5683
  // duration() writes "-" for 0, which here would read as "no numbers".
5443
5684
  uptime: s ? s.uptimeSec >= 1 ? duration(s.uptimeSec) : "0s" : "-"
5444
5685
  };
5445
5686
  });
5446
5687
  }
5447
5688
 
5448
- // src/commands/vm/traffic.ts
5449
- import { Command as Command38 } from "commander";
5450
- var trafficCommand = new Command38("traffic").description(`requests, errors, latency, bytes and wakes through a box's HTTPS names (last ${TRAFFIC_KEEP_DAYS} days at most)`).argument("<name>", "box name").option("--since <when>", "how far back: 1h, 24h, 7d, or a date like 2026-11-19 (default 24h)").option("--host <name>", "one of the box's names only, e.g. web.kvbox.app").option("--json", "print as JSON").action(async (name, opts, cmd) => {
5451
- const q = new URLSearchParams();
5452
- if (opts.since !== void 0) q.set("since", sinceOf(opts.since));
5453
- if (opts.host !== void 0) q.set("host", opts.host);
5454
- const client = await clientFor(cmd.optsWithGlobals());
5455
- try {
5456
- if (client.target.kind !== "cloud") throw new KvboxError("traffic is counted by the kvbox cloud's edge: kvbox login first");
5457
- const report = await client.machineTraffic(name, q.size === 0 ? "" : `?${q.toString()}`);
5458
- if (opts.json) json(report);
5459
- else if (report.totals.requests === 0) info(`no requests reached ${name} through its HTTPS names since ${when(report.since)}`);
5460
- else process.stdout.write(block2(report));
5461
- } finally {
5462
- await client.close();
5463
- }
5464
- });
5465
- var UNITS = { m: 6e4, h: 36e5, d: 864e5 };
5466
- function sinceOf(text2, now = Date.now()) {
5467
- const span = /^(\d+)([mhd])$/.exec(text2.trim());
5468
- if (span) return new Date(now - Number(span[1]) * UNITS[span[2]]).toISOString();
5469
- const t = Date.parse(text2);
5470
- if (Number.isNaN(t)) throw new KvboxError(`--since ${text2}: write a span like 1h, 24h or 7d, or a date like 2026-11-19`);
5471
- return new Date(t).toISOString();
5472
- }
5473
- var when = (iso2) => `${iso2.slice(0, 16).replace("T", " ")} UTC`;
5474
- var n = (v) => v.toLocaleString("en-US");
5475
- function bytes(v) {
5476
- if (v < 1e3) return `${v} B`;
5477
- const units = ["kB", "MB", "GB", "TB"];
5478
- let x = v;
5479
- let u = -1;
5480
- while (x >= 1e3 && u < units.length - 1) {
5481
- x /= 1e3;
5482
- u++;
5483
- }
5484
- return `${x < 10 ? x.toFixed(1) : Math.round(x)} ${units[u]}`;
5485
- }
5486
- var ms = (v) => v === null ? "-" : v >= 1e3 ? `${v / 1e3} s` : `${v} ms`;
5487
- var share = (part, whole) => whole === 0 || part === 0 ? "" : color.dim(` (${(part / whole * 100).toFixed(part === whole ? 0 : 1)}%)`);
5488
- function block2(r) {
5489
- const t = r.totals;
5490
- const rows2 = [
5491
- ["name", boxName(r.box)],
5492
- ["window", `${when(r.since)} to ${when(r.until)}`],
5493
- ["hosts", r.host ?? (r.hosts.join(", ") || "-")],
5494
- ["requests", n(t.requests)],
5495
- ["2xx", n(t.s2xx) + share(t.s2xx, t.requests)],
5496
- ["3xx", n(t.s3xx) + share(t.s3xx, t.requests)],
5497
- ["4xx", n(t.s4xx) + share(t.s4xx, t.requests)],
5498
- ["5xx", (t.s5xx > 0 ? color.red(n(t.s5xx)) : "0") + share(t.s5xx, t.requests)],
5499
- ["latency", `p50 \u2264 ${ms(t.p50Ms)}, p95 \u2264 ${ms(t.p95Ms)}`],
5500
- ["bytes in", bytes(t.bytesIn)],
5501
- ["bytes out", bytes(t.bytesOut)],
5502
- ["wakes", t.wakes === 0 ? "0" : `${n(t.wakes)}, waited ${ms(t.wakeWaitMs)} on average`]
5503
- ];
5504
- const width2 = Math.max(...rows2.map(([k]) => k.length));
5505
- const lines = rows2.map(([k, v]) => `${color.dim(k.padStart(width2))} ${v}`);
5506
- lines.push(color.dim("published ports and SSH do not pass the edge and are not counted"));
5507
- return `${lines.join("\n")}
5508
- `;
5509
- }
5510
-
5511
5689
  // src/commands/vm/unlink.ts
5512
- import { Command as Command39 } from "commander";
5513
- var unlinkCommand = new Command39("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) => {
5690
+ import { Command as Command41 } from "commander";
5691
+ var unlinkCommand = new Command41("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) => {
5514
5692
  const port = parseLinkPort(opts.port);
5515
5693
  if (!await confirm(`Cut box ${from} off from box ${name} port ${port}? Its open connections close too.`, opts.yes ?? false)) {
5516
5694
  info("cancelled");
@@ -5531,8 +5709,8 @@ var unlinkCommand = new Command39("unlink").description("take a link away (kvbox
5531
5709
  });
5532
5710
 
5533
5711
  // src/commands/vm/update.ts
5534
- import { Command as Command40 } from "commander";
5535
- var updateCommand = new Command40("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) => {
5712
+ import { Command as Command42 } from "commander";
5713
+ var updateCommand = new Command42("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) => {
5536
5714
  const client = await clientFor(cmd.optsWithGlobals());
5537
5715
  try {
5538
5716
  const before = pickRef(await boxesFor(client, name), name, me(client));
@@ -5554,8 +5732,8 @@ var updateCommand = new Command40("update").description("move a box onto the cur
5554
5732
  });
5555
5733
 
5556
5734
  // src/commands/vm/wake.ts
5557
- import { Command as Command41 } from "commander";
5558
- var wakeCommand = new Command41("wake").description("continue a hibernated box where it left off (same name, IP and disk)").argument("<name>", "box name").option("--force", "skip the capacity guard").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
5735
+ import { Command as Command43 } from "commander";
5736
+ var wakeCommand = new Command43("wake").description("continue a hibernated box where it left off (same name, IP and disk)").argument("<name>", "box name").option("--force", "skip the capacity guard").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
5559
5737
  const client = await clientFor(cmd.optsWithGlobals());
5560
5738
  try {
5561
5739
  const box2 = await spin(`waking ${name} (loading its memory from disk)\u2026`, client.wakeMachine(name, opts.force ?? false));
@@ -5567,7 +5745,7 @@ var wakeCommand = new Command41("wake").description("continue a hibernated box w
5567
5745
  });
5568
5746
 
5569
5747
  // src/commands/vm/index.ts
5570
- var vmCommand = new Command42("vm").enablePositionalOptions().description("manage boxes (each one is a Firecracker microVM)").addCommand(newCommand).addCommand(forkCommand).addCommand(lsCommand).addCommand(getCommand).addCommand(connectCommand).addCommand(execCommand).addCommand(cpCommand).addCommand(stopCommand).addCommand(startCommand).addCommand(pauseCommand).addCommand(resumeCommand).addCommand(hibernateCommand).addCommand(wakeCommand).addCommand(updateCommand).addCommand(rescaleCommand).addCommand(setCommand).addCommand(usageCommand).addCommand(trafficCommand).addCommand(topCommand).addCommand(proxyCommand).addCommand(hookCommand).addCommand(backupCommand).addCommand(linkCommand).addCommand(unlinkCommand).addCommand(linksCommand).addCommand(rmCommand4);
5748
+ var vmCommand = new Command44("vm").enablePositionalOptions().description("manage boxes (each one is a Firecracker microVM)").addCommand(newCommand).addCommand(forkCommand).addCommand(lsCommand).addCommand(getCommand).addCommand(connectCommand).addCommand(execCommand).addCommand(cpCommand).addCommand(stopCommand).addCommand(startCommand).addCommand(restartCommand).addCommand(pauseCommand).addCommand(resumeCommand).addCommand(hibernateCommand).addCommand(wakeCommand).addCommand(updateCommand).addCommand(rescaleCommand).addCommand(setCommand).addCommand(usageCommand).addCommand(trafficCommand).addCommand(resourcesCommand).addCommand(topCommand).addCommand(proxyCommand).addCommand(hookCommand).addCommand(backupCommand).addCommand(linkCommand).addCommand(unlinkCommand).addCommand(linksCommand).addCommand(rmCommand4);
5571
5749
  for (const cmd of vmCommand.commands) if (cmd !== proxyCommand && cmd !== hookCommand && cmd !== backupCommand) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
5572
5750
  var vmAliases = [newCommand, lsCommand, getCommand, connectCommand, execCommand, cpCommand, stopCommand, startCommand, pauseCommand, resumeCommand, hibernateCommand, wakeCommand, rmCommand4, claimCommand];
5573
5751
 
@@ -5576,7 +5754,7 @@ import { hostname as osHostname2 } from "os";
5576
5754
  import { createInterface as createInterface2 } from "readline/promises";
5577
5755
  import { setTimeout as sleep4 } from "timers/promises";
5578
5756
  import { Writable } from "stream";
5579
- import { Command as Command43 } from "commander";
5757
+ import { Command as Command45 } from "commander";
5580
5758
 
5581
5759
  // src/browser.ts
5582
5760
  import { spawn as spawn5 } from "child_process";
@@ -5613,7 +5791,7 @@ function openBrowser(url) {
5613
5791
  }
5614
5792
 
5615
5793
  // src/commands/login.ts
5616
- var loginCommand = new Command43("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("--password", "log in with email and password instead of approving a code in the web app").option("-e, --email <email>", "account email, for a password login (prompted otherwise)").option("--password-stdin", "read the password from the first line of stdin (for scripts)").action(async (urlArg, opts) => {
5794
+ var loginCommand = new Command45("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("--password", "log in with email and password instead of approving a code in the web app").option("-e, --email <email>", "account email, for a password login (prompted otherwise)").option("--password-stdin", "read the password from the first line of stdin (for scripts)").action(async (urlArg, opts) => {
5617
5795
  const url = normalizeUrl(urlArg ?? DEFAULT_CLOUD_URL);
5618
5796
  const byPassword = opts.password === true || opts.passwordStdin === true || opts.email !== void 0;
5619
5797
  const session = byPassword ? await runLogin(url, await readCredentials(opts), paths()) : await runDeviceLogin(url, paths());
@@ -5723,8 +5901,8 @@ async function firstLine(stream) {
5723
5901
  }
5724
5902
 
5725
5903
  // src/commands/logout.ts
5726
- import { Command as Command44 } from "commander";
5727
- var logoutCommand = new Command44("logout").description("log out of the control plane; commands target this machine's kvbox-server again").action(async () => {
5904
+ import { Command as Command46 } from "commander";
5905
+ var logoutCommand = new Command46("logout").description("log out of the control plane; commands target this machine's kvbox-server again").action(async () => {
5728
5906
  const p = paths();
5729
5907
  const session = await readSession(p).catch(() => null);
5730
5908
  switch (await runLogout(p)) {
@@ -5762,8 +5940,8 @@ async function runLogout(p = paths()) {
5762
5940
  }
5763
5941
 
5764
5942
  // src/commands/whoami.ts
5765
- import { Command as Command45 } from "commander";
5766
- var whoamiCommand = new Command45("whoami").description("show which account and control plane commands target (or local mode)").option("--json", "print as JSON").action(async (opts, cmd) => {
5943
+ import { Command as Command47 } from "commander";
5944
+ var whoamiCommand = new Command47("whoami").description("show which account and control plane commands target (or local mode)").option("--json", "print as JSON").action(async (opts, cmd) => {
5767
5945
  if (!cmd.optsWithGlobals().local && envLogin()) {
5768
5946
  const target = await resolveTarget({});
5769
5947
  if (target.kind !== "cloud") return;
@@ -5788,10 +5966,10 @@ function describeSession(session) {
5788
5966
  }
5789
5967
 
5790
5968
  // src/commands/key/index.ts
5791
- import { Command as Command49 } from "commander";
5969
+ import { Command as Command51 } from "commander";
5792
5970
 
5793
5971
  // src/commands/key/create.ts
5794
- import { Command as Command46 } from "commander";
5972
+ import { Command as Command48 } from "commander";
5795
5973
 
5796
5974
  // src/commands/key/shared.ts
5797
5975
  async function keyClient(cmd) {
@@ -5828,7 +6006,7 @@ function expiryText(expiresAt, now = Date.now()) {
5828
6006
  }
5829
6007
 
5830
6008
  // src/commands/key/create.ts
5831
- var createCommand3 = new Command46("create").description("make an API key for a program: CI, an agent, the SDK (the key is shown once)").argument("<name>", "what to call the key: lowercase letters, digits, '.', '_' or '-'").option("--expires <when>", `when it stops working: a duration (30d, 12h; m is minutes), a day (2027-01-31), or never; ${DEFAULT_API_KEY_DAYS}d by default`).option("--json", "print as JSON").action(async (name, opts, cmd) => {
6009
+ var createCommand3 = new Command48("create").description("make an API key for a program: CI, an agent, the SDK (the key is shown once)").argument("<name>", "what to call the key: lowercase letters, digits, '.', '_' or '-'").option("--expires <when>", `when it stops working: a duration (30d, 12h; m is minutes), a day (2027-01-31), or never; ${DEFAULT_API_KEY_DAYS}d by default`).option("--json", "print as JSON").action(async (name, opts, cmd) => {
5832
6010
  const expiresAt = opts.expires === void 0 ? void 0 : parseExpires(opts.expires);
5833
6011
  const client = await keyClient(cmd);
5834
6012
  try {
@@ -5846,8 +6024,8 @@ var createCommand3 = new Command46("create").description("make an API key for a
5846
6024
  });
5847
6025
 
5848
6026
  // src/commands/key/ls.ts
5849
- import { Command as Command47 } from "commander";
5850
- var lsCommand5 = new Command47("ls").alias("list").description("list your API keys (never the keys themselves)").option("--json", "print as JSON").action(async (opts, cmd) => {
6027
+ import { Command as Command49 } from "commander";
6028
+ var lsCommand5 = new Command49("ls").alias("list").description("list your API keys (never the keys themselves)").option("--json", "print as JSON").action(async (opts, cmd) => {
5851
6029
  const client = await keyClient(cmd);
5852
6030
  try {
5853
6031
  const keys = await client.listApiKeys();
@@ -5866,8 +6044,8 @@ var lsCommand5 = new Command47("ls").alias("list").description("list your API ke
5866
6044
  });
5867
6045
 
5868
6046
  // src/commands/key/rm.ts
5869
- import { Command as Command48 } from "commander";
5870
- var rmCommand5 = new Command48("rm").alias("remove").description("remove an API key: whatever uses it stops working").argument("<name>", "the key's name (kvbox key ls)").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
6047
+ import { Command as Command50 } from "commander";
6048
+ var rmCommand5 = new Command50("rm").alias("remove").description("remove an API key: whatever uses it stops working").argument("<name>", "the key's name (kvbox key ls)").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
5871
6049
  const client = await keyClient(cmd);
5872
6050
  try {
5873
6051
  if (!await confirm(`Remove API key ${name}? Whatever uses it stops working.`, opts.yes ?? false)) {
@@ -5883,14 +6061,14 @@ var rmCommand5 = new Command48("rm").alias("remove").description("remove an API
5883
6061
  });
5884
6062
 
5885
6063
  // src/commands/key/index.ts
5886
- var keyCommand = new Command49("key").aliases(["keys"]).description("API keys: named tokens a program (CI, an agent, the SDK) uses as KVBOX_TOKEN in place of a login").addCommand(createCommand3).addCommand(lsCommand5).addCommand(rmCommand5);
6064
+ var keyCommand = new Command51("key").aliases(["keys"]).description("API keys: named tokens a program (CI, an agent, the SDK) uses as KVBOX_TOKEN in place of a login").addCommand(createCommand3).addCommand(lsCommand5).addCommand(rmCommand5);
5887
6065
 
5888
6066
  // src/commands/integration/index.ts
5889
- import { Command as Command51 } from "commander";
6067
+ import { Command as Command53 } from "commander";
5890
6068
 
5891
6069
  // src/commands/integration/ls.ts
5892
- import { Command as Command50 } from "commander";
5893
- var lsCommand6 = new Command50("ls").alias("list").description("list the accounts connected for your boxes (GitHub, Claude Code), per slug; connect one in the web app").option("--json", "print as JSON").action(async (opts, cmd) => {
6070
+ import { Command as Command52 } from "commander";
6071
+ var lsCommand6 = new Command52("ls").alias("list").description("list the accounts connected for your boxes (GitHub, Claude Code), per slug; connect one in the web app").option("--json", "print as JSON").action(async (opts, cmd) => {
5894
6072
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
5895
6073
  try {
5896
6074
  if (client.target.kind !== "cloud") throw new KvboxError("integrations belong to an account on the kvbox cloud: kvbox login first");
@@ -5919,14 +6097,14 @@ var lsCommand6 = new Command50("ls").alias("list").description("list the account
5919
6097
  });
5920
6098
 
5921
6099
  // src/commands/integration/index.ts
5922
- var integrationCommand = new Command51("integration").aliases(["integrations"]).description("integrations: accounts (GitHub, Claude Code) connected once in the web app and turned on per box with --integration").addCommand(lsCommand6);
6100
+ var integrationCommand = new Command53("integration").aliases(["integrations"]).description("integrations: accounts (GitHub, Claude Code) connected once in the web app and turned on per box with --integration").addCommand(lsCommand6);
5923
6101
 
5924
6102
  // src/commands/snapshots/index.ts
5925
- import { Command as Command55 } from "commander";
6103
+ import { Command as Command57 } from "commander";
5926
6104
 
5927
6105
  // src/commands/snapshots/ls.ts
5928
- import { Command as Command52 } from "commander";
5929
- var lsCommand7 = new Command52("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) => {
6106
+ import { Command as Command54 } from "commander";
6107
+ var lsCommand7 = new Command54("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) => {
5930
6108
  const client = await clientFor(cmd.optsWithGlobals());
5931
6109
  try {
5932
6110
  const cloud = client.target.kind === "cloud";
@@ -5957,8 +6135,8 @@ var lsCommand7 = new Command52("ls").description("list snapshots (yours and your
5957
6135
  });
5958
6136
 
5959
6137
  // src/commands/snapshots/new.ts
5960
- import { Command as Command53 } from "commander";
5961
- var newCommand2 = new Command53("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 (box2, name, opts, cmd) => {
6138
+ import { Command as Command55 } from "commander";
6139
+ var newCommand2 = new Command55("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 (box2, name, opts, cmd) => {
5962
6140
  const client = await clientFor(cmd.optsWithGlobals());
5963
6141
  try {
5964
6142
  const req = { box: box2, name, ...opts.replace ? { replace: true } : {} };
@@ -5971,8 +6149,8 @@ var newCommand2 = new Command53("new").description("freeze a running box (memory
5971
6149
  });
5972
6150
 
5973
6151
  // src/commands/snapshots/rm.ts
5974
- import { Command as Command54 } from "commander";
5975
- var rmCommand6 = new Command54("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) => {
6152
+ import { Command as Command56 } from "commander";
6153
+ var rmCommand6 = new Command56("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) => {
5976
6154
  if (!await confirm(`Delete snapshot ${name}?`, opts.yes ?? false)) {
5977
6155
  info("cancelled");
5978
6156
  process.exitCode = 1;
@@ -5988,14 +6166,14 @@ var rmCommand6 = new Command54("rm").description("delete a snapshot (boxes made
5988
6166
  });
5989
6167
 
5990
6168
  // src/commands/snapshots/index.ts
5991
- var snapshotsCommand = new Command55("snapshots").aliases(["snapshot", "snap"]).description("freeze running boxes into snapshots and manage them").addCommand(newCommand2).addCommand(lsCommand7).addCommand(rmCommand6);
6169
+ var snapshotsCommand = new Command57("snapshots").aliases(["snapshot", "snap"]).description("freeze running boxes into snapshots and manage them").addCommand(newCommand2).addCommand(lsCommand7).addCommand(rmCommand6);
5992
6170
  for (const cmd of snapshotsCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
5993
6171
 
5994
6172
  // src/commands/org/index.ts
5995
- import { Command as Command61 } from "commander";
6173
+ import { Command as Command63 } from "commander";
5996
6174
 
5997
6175
  // src/commands/org/ls.ts
5998
- import { Command as Command56 } from "commander";
6176
+ import { Command as Command58 } from "commander";
5999
6177
 
6000
6178
  // src/commands/org/context.ts
6001
6179
  var NOT_LOGGED_IN2 = "orgs live on the control plane: kvbox login first";
@@ -6015,7 +6193,7 @@ function orgFor(opts, target) {
6015
6193
  }
6016
6194
 
6017
6195
  // src/commands/org/ls.ts
6018
- var lsCommand8 = new Command56("ls").description("list the orgs you belong to and your role in each").option("--json", "print as JSON").action(async (opts, cmd) => {
6196
+ var lsCommand8 = new Command58("ls").description("list the orgs you belong to and your role in each").option("--json", "print as JSON").action(async (opts, cmd) => {
6019
6197
  const client = await cloudClientFor(cmd.optsWithGlobals());
6020
6198
  try {
6021
6199
  const orgs = await client.listOrgs();
@@ -6037,8 +6215,8 @@ function orgRows(orgs) {
6037
6215
  }
6038
6216
 
6039
6217
  // src/commands/org/members.ts
6040
- import { Command as Command57, Option as Option4 } from "commander";
6041
- var lsCommand9 = new Command57("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) => {
6218
+ import { Command as Command59, Option as Option4 } from "commander";
6219
+ var lsCommand9 = new Command59("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) => {
6042
6220
  const client = await cloudClientFor(cmd.optsWithGlobals());
6043
6221
  try {
6044
6222
  const org = await client.getOrg(orgFor(opts, client.target));
@@ -6052,7 +6230,7 @@ var lsCommand9 = new Command57("ls").description("list an org's members and thei
6052
6230
  await client.close();
6053
6231
  }
6054
6232
  });
6055
- var addCommand2 = new Command57("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) => {
6233
+ var addCommand2 = new Command59("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) => {
6056
6234
  const client = await cloudClientFor(cmd.optsWithGlobals());
6057
6235
  try {
6058
6236
  const slug = orgFor(opts, client.target);
@@ -6062,7 +6240,7 @@ var addCommand2 = new Command57("add").description("add a user to an org (admins
6062
6240
  await client.close();
6063
6241
  }
6064
6242
  });
6065
- var rmCommand7 = new Command57("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) => {
6243
+ var rmCommand7 = new Command59("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) => {
6066
6244
  const client = await cloudClientFor(cmd.optsWithGlobals());
6067
6245
  try {
6068
6246
  const slug = orgFor(opts, client.target);
@@ -6078,11 +6256,11 @@ var rmCommand7 = new Command57("rm").description("remove a member (or leave: rem
6078
6256
  await client.close();
6079
6257
  }
6080
6258
  });
6081
- var membersCommand = new Command57("members").description("who is in an org and what they may do").addCommand(lsCommand9).addCommand(addCommand2).addCommand(rmCommand7);
6259
+ var membersCommand = new Command59("members").description("who is in an org and what they may do").addCommand(lsCommand9).addCommand(addCommand2).addCommand(rmCommand7);
6082
6260
 
6083
6261
  // src/commands/org/new.ts
6084
- import { Command as Command58 } from "commander";
6085
- var newCommand3 = new Command58("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) => {
6262
+ import { Command as Command60 } from "commander";
6263
+ var newCommand3 = new Command60("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) => {
6086
6264
  const client = await cloudClientFor(cmd.optsWithGlobals());
6087
6265
  try {
6088
6266
  const org = await client.createOrg({ slug, name: opts.name ?? slug });
@@ -6098,8 +6276,8 @@ var newCommand3 = new Command58("new").description("create an org; you become it
6098
6276
  });
6099
6277
 
6100
6278
  // src/commands/org/rm.ts
6101
- import { Command as Command59 } from "commander";
6102
- var rmCommand8 = new Command59("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) => {
6279
+ import { Command as Command61 } from "commander";
6280
+ var rmCommand8 = new Command61("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) => {
6103
6281
  if (!await confirm(`Delete org ${slug}? Its members lose access; its slug stays taken.`, opts.yes ?? false)) {
6104
6282
  info("cancelled");
6105
6283
  process.exitCode = 1;
@@ -6115,8 +6293,8 @@ var rmCommand8 = new Command59("rm").description("delete an org (owners only; re
6115
6293
  });
6116
6294
 
6117
6295
  // src/commands/org/role.ts
6118
- import { Argument, Command as Command60 } from "commander";
6119
- var roleCommand = new Command60("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) => {
6296
+ import { Argument, Command as Command62 } from "commander";
6297
+ var roleCommand = new Command62("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) => {
6120
6298
  const client = await cloudClientFor(cmd.optsWithGlobals());
6121
6299
  try {
6122
6300
  const slug = orgFor(opts, client.target);
@@ -6128,11 +6306,11 @@ var roleCommand = new Command60("role").description("change a member's role (own
6128
6306
  });
6129
6307
 
6130
6308
  // src/commands/org/index.ts
6131
- var orgCommand = new Command61("org").description("orgs: shared slugs that own boxes, with owners, admins and members").addCommand(lsCommand8).addCommand(newCommand3).addCommand(membersCommand).addCommand(roleCommand).addCommand(rmCommand8);
6309
+ var orgCommand = new Command63("org").description("orgs: shared slugs that own boxes, with owners, admins and members").addCommand(lsCommand8).addCommand(newCommand3).addCommand(membersCommand).addCommand(roleCommand).addCommand(rmCommand8);
6132
6310
 
6133
6311
  // src/commands/usage.ts
6134
- import { Command as Command62 } from "commander";
6135
- var usageCommand2 = new Command62("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) => {
6312
+ import { Command as Command64 } from "commander";
6313
+ var usageCommand2 = new Command64("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) => {
6136
6314
  for (const [name, value] of [
6137
6315
  ["since", opts.since],
6138
6316
  ["until", opts.until]
@@ -6329,8 +6507,8 @@ function userRows(r) {
6329
6507
  }
6330
6508
 
6331
6509
  // src/commands/credit.ts
6332
- import { Command as Command63 } from "commander";
6333
- var creditCommand = new Command63("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) => {
6510
+ import { Command as Command65 } from "commander";
6511
+ var creditCommand = new Command65("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) => {
6334
6512
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
6335
6513
  try {
6336
6514
  if (client.target.kind === "local") throw new KvboxError("credit lives on the control plane: kvbox login first");
@@ -6351,16 +6529,25 @@ function creditRow(b, me2) {
6351
6529
  owner: b.slug === me2 ? "private" : boxName(b.slug),
6352
6530
  credit: b.balance > 0 ? left : color.red(left),
6353
6531
  promo: b.promo > 0 && b.promoExpiresAt ? `${money(b.promo, b.currency)} until ${b.promoExpiresAt.slice(0, 10)}` : "-",
6354
- "topped up": money(b.topUps, b.currency),
6532
+ added: money(addedOf(b), b.currency),
6533
+ transferred: transferredOf(b),
6355
6534
  spent: money(b.spent, b.currency),
6356
6535
  // Suspended (#76): the sweep hibernated the boxes at zero; a top-up brings them back.
6357
6536
  state: b.suspendedAt ? color.red("suspended") : b.since === null ? color.dim("no credit yet") : "ok"
6358
6537
  };
6359
6538
  }
6539
+ function addedOf(b) {
6540
+ const split = b.added + b.welcome + b.transferredIn - b.transferredOut;
6541
+ return split === 0 && b.topUps !== 0 ? b.topUps : b.added + b.welcome;
6542
+ }
6543
+ function transferredOf(b) {
6544
+ const parts = [b.transferredIn > 0 ? `+${money(b.transferredIn, b.currency)}` : "", b.transferredOut > 0 ? `-${money(b.transferredOut, b.currency)}` : ""];
6545
+ return parts.filter(Boolean).join(" ") || "-";
6546
+ }
6360
6547
 
6361
6548
  // src/commands/redeem.ts
6362
- import { Command as Command64 } from "commander";
6363
- var redeemCommand = new Command64("redeem").description("redeem a promo code for credit, on your account or (--org) an org you own").argument("<code>", "the code, like KV-7F3K-9QXM-2HBD").option("--org <slug>", "give the credit to this org, which you own; it cannot be moved later").option("--json", "print as JSON").action(async (code, opts, cmd) => {
6549
+ import { Command as Command66 } from "commander";
6550
+ var redeemCommand = new Command66("redeem").description("redeem a promo code for credit, on your account or (--org) an org you own").argument("<code>", "the code, like KV-7F3K-9QXM-2HBD").option("--org <slug>", "give the credit to this org, which you own; it cannot be moved later").option("--json", "print as JSON").action(async (code, opts, cmd) => {
6364
6551
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
6365
6552
  try {
6366
6553
  if (client.target.kind === "local") throw new KvboxError("codes are redeemed on the control plane: kvbox login first");
@@ -6380,12 +6567,12 @@ var redeemCommand = new Command64("redeem").description("redeem a promo code for
6380
6567
  // src/commands/deploy/index.ts
6381
6568
  import { access as access5, readFile as readFile7 } from "fs/promises";
6382
6569
  import { basename as basename2, resolve as resolve3 } from "path";
6383
- import { Command as Command65, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
6570
+ import { Command as Command67, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
6384
6571
 
6385
6572
  // src/commands/deploy/config.ts
6386
6573
  import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
6387
6574
  import { isAbsolute, join as join6, normalize, relative as relative2 } from "path";
6388
- import { z as z15 } from "zod";
6575
+ import { z as z16 } from "zod";
6389
6576
 
6390
6577
  // src/commands/deploy/templates/docker.ts
6391
6578
  import { readFile as readFile4 } from "fs/promises";
@@ -6809,21 +6996,21 @@ function detectTemplates(pkg, dir = NO_FACTS) {
6809
6996
  var DEPLOY_AUTO_HIBERNATE_SEC = 3600;
6810
6997
  var CONFIG_FILE = "kvbox.json";
6811
6998
  var BOX_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
6812
- var DeployConfigSchema = z15.object({
6813
- template: z15.enum(TEMPLATE_IDS),
6814
- name: z15.string().regex(BOX_NAME_RE, "1-12 chars, lowercase letters, digits and '-', starting with a letter or digit"),
6999
+ var DeployConfigSchema = z16.object({
7000
+ template: z16.enum(TEMPLATE_IDS),
7001
+ name: z16.string().regex(BOX_NAME_RE, "1-12 chars, lowercase letters, digits and '-', starting with a letter or digit"),
6815
7002
  /** The org whose box it is; absent for the user's own. */
6816
- org: z15.string().regex(ORG_SLUG_RE, "not an org slug").optional(),
7003
+ org: z16.string().regex(ORG_SLUG_RE, "not an org slug").optional(),
6817
7004
  /** The HTTPS name (`<subdomain>.kvbox.app`); absent when deploying to this machine's own host. */
6818
- subdomain: z15.string().check((ctx) => {
7005
+ subdomain: z16.string().check((ctx) => {
6819
7006
  const problem = subdomainProblem(ctx.value);
6820
7007
  if (problem) ctx.issues.push({ code: "custom", message: problem, input: ctx.value });
6821
7008
  }).optional(),
6822
- size: z15.enum(SIZE_NAMES).optional(),
7009
+ size: z16.enum(SIZE_NAMES).optional(),
6823
7010
  /** The build output directory, relative to the app; the template's default when absent. */
6824
- dist: z15.string().optional(),
7011
+ dist: z16.string().optional(),
6825
7012
  /** The port a Next.js app or Node server serves; the template's (3000) when absent. */
6826
- port: z15.number().int().min(1).max(65535).optional()
7013
+ port: z16.number().int().min(1).max(65535).optional()
6827
7014
  });
6828
7015
  var SERVICE_KEY_RE = /^[a-z][a-z0-9-]{0,19}$/;
6829
7016
  var RESERVED_SERVICE_KEYS = ["app", "agent", "init", "volumes"];
@@ -6835,43 +7022,43 @@ var POSTGRES_PORT = 5432;
6835
7022
  var POSTGRES_IMAGE = "postgres:17";
6836
7023
  var POSTGRES_ENV = "DATABASE_URL";
6837
7024
  var IMAGE_RE = /^[a-z0-9][a-z0-9._/:@-]*$/;
6838
- var ServiceSchema = z15.strictObject({
6839
- template: z15.enum([...TEMPLATE_IDS, POSTGRES]),
7025
+ var ServiceSchema = z16.strictObject({
7026
+ template: z16.enum([...TEMPLATE_IDS, POSTGRES]),
6840
7027
  /** The service's directory, relative to the one holding kvbox.json; every template but postgres has one. */
6841
- dir: z15.string().min(1).optional(),
7028
+ dir: z16.string().min(1).optional(),
6842
7029
  /** A postgres service's image, `postgres:17` when absent (`pgvector/pgvector:pg17` for vectors). */
6843
- image: z15.string().regex(IMAGE_RE, "an image name like postgres:17").optional(),
7030
+ image: z16.string().regex(IMAGE_RE, "an image name like postgres:17").optional(),
6844
7031
  /** The volume (a key of `volumes`) a postgres service keeps its data on. */
6845
- volume: z15.string().optional(),
7032
+ volume: z16.string().optional(),
6846
7033
  /** The box variable a postgres service's URL is written to, `DATABASE_URL` when absent. */
6847
- env: z15.string().optional(),
7034
+ env: z16.string().optional(),
6848
7035
  /** A docker service's build context, relative to kvbox.json, when it is not `dir` (a monorepo built from its root); the Dockerfile stays in `dir`. */
6849
- context: z15.string().min(1).optional(),
6850
- dist: z15.string().optional(),
7036
+ context: z16.string().min(1).optional(),
7037
+ dist: z16.string().optional(),
6851
7038
  /**
6852
7039
  * A command run once per deploy in the service's new version (a docker service: in a container of
6853
7040
  * the new image; node, nextjs: in the new source, installed and built), with the box's variables,
6854
7041
  * before it replaces the running one. Migrations, mostly. A failing one stops that service's deploy.
6855
7042
  */
6856
- release: z15.string().optional(),
7043
+ release: z16.string().optional(),
6857
7044
  /** The box port of a service with its own server; the template's (3000) when absent. */
6858
- port: z15.number().int().min(1).max(65535).optional(),
7045
+ port: z16.number().int().min(1).max(65535).optional(),
6859
7046
  /** The URL paths that go to this service, each with everything under it; the prefix is kept. */
6860
- paths: z15.array(z15.string().regex(ROUTE_RE, "a path like / or /api, no trailing slash")).min(1).optional()
7047
+ paths: z16.array(z16.string().regex(ROUTE_RE, "a path like / or /api, no trailing slash")).min(1).optional()
6861
7048
  });
6862
- var StackConfigSchema = z15.strictObject({
7049
+ var StackConfigSchema = z16.strictObject({
6863
7050
  name: DeployConfigSchema.shape.name.optional(),
6864
7051
  org: DeployConfigSchema.shape.org,
6865
7052
  subdomain: DeployConfigSchema.shape.subdomain,
6866
7053
  size: DeployConfigSchema.shape.size,
6867
7054
  /** The stack's volumes, name to size ("10GB"): made for its box and attached to it on the first deploy that needs one. */
6868
- volumes: z15.record(z15.string(), z15.string()).optional(),
6869
- services: z15.record(z15.string(), ServiceSchema)
7055
+ volumes: z16.record(z16.string(), z16.string()).optional(),
7056
+ services: z16.record(z16.string(), ServiceSchema)
6870
7057
  });
6871
7058
  function volumeGib(text2) {
6872
- const mib = parseMib(text2);
6873
- if (mib === void 0 || mib === 0 || mib % 1024 !== 0 || mib / 1024 > MAX_VOLUME_GIB) return void 0;
6874
- return mib / 1024;
7059
+ const mib2 = parseMib(text2);
7060
+ if (mib2 === void 0 || mib2 === 0 || mib2 % 1024 !== 0 || mib2 / 1024 > MAX_VOLUME_GIB) return void 0;
7061
+ return mib2 / 1024;
6875
7062
  }
6876
7063
  function stackServices(stack, defaultPort, exposed = /* @__PURE__ */ new Map()) {
6877
7064
  const services = [];
@@ -7244,16 +7431,16 @@ var PROXY = (port) => [
7244
7431
  "proxy_buffering off;",
7245
7432
  "proxy_read_timeout 3600s;"
7246
7433
  ];
7247
- var block3 = (head, body) => [` ${head} {`, ...body.map((l) => ` ${l}`), " }", ""];
7434
+ var block4 = (head, body) => [` ${head} {`, ...body.map((l) => ` ${l}`), " }", ""];
7248
7435
  function locations(service, path) {
7249
7436
  const dist = `/srv/app/${service.key}/dist`;
7250
7437
  if (service.static) {
7251
- if (path === "/") return block3("location /", [`root ${dist};`, "try_files $uri $uri/ /index.html;"]);
7252
- return [...block3(`location = ${path}`, [`return 301 ${path}/;`]), ...block3(`location ${path}/`, [`alias ${dist}/;`, `try_files $uri $uri/ ${path}/index.html;`])];
7438
+ if (path === "/") return block4("location /", [`root ${dist};`, "try_files $uri $uri/ /index.html;"]);
7439
+ return [...block4(`location = ${path}`, [`return 301 ${path}/;`]), ...block4(`location ${path}/`, [`alias ${dist}/;`, `try_files $uri $uri/ ${path}/index.html;`])];
7253
7440
  }
7254
7441
  const proxy = PROXY(service.port);
7255
- if (path === "/") return block3("location /", proxy);
7256
- return [...block3(`location = ${path}`, proxy), ...block3(`location ${path}/`, proxy)];
7442
+ if (path === "/") return block4("location /", proxy);
7443
+ return [...block4(`location = ${path}`, proxy), ...block4(`location ${path}/`, proxy)];
7257
7444
  }
7258
7445
  function stackSite(services) {
7259
7446
  const routed = services.flatMap((s) => s.paths.map((path) => ({ service: s, path })));
@@ -7281,7 +7468,7 @@ function stackSite(services) {
7281
7468
  "",
7282
7469
  ...routed.flatMap((r) => locations(r.service, r.path)),
7283
7470
  // No service at the top: say so instead of nginx's own welcome page.
7284
- ...root ? [] : block3("location /", ["return 404;"]),
7471
+ ...root ? [] : block4("location /", ["return 404;"]),
7285
7472
  "}",
7286
7473
  ""
7287
7474
  ].join("\n");
@@ -7645,7 +7832,7 @@ async function readPackageJson(dir) {
7645
7832
  }
7646
7833
 
7647
7834
  // src/commands/deploy/index.ts
7648
- var deployCommand = new Command65("deploy").description("put the app in this directory (React, Next.js, a Node server, a Dockerfile or a static site) on a box with its own HTTPS address; redeploy by running it again").argument("[dir]", "the app's directory (default: the current one)").addOption(new Option5("-t, --template <template>", "what kind of app it is (detected from package.json and the directory when not given)").choices(TEMPLATE_IDS)).option("-n, --name <name>", "the box's name (default: the directory's name)").option("--sub <subdomain>", "its HTTPS name, https://<subdomain>.kvbox.app (default: the box's name)").addOption(new Option5("-s, --size <size>", "size of the box when it has to be made").choices(SIZE_NAMES)).option("--port <port>", "the box port of a Next.js app, Node server or container (default 3000; saved to kvbox.json)", parsePort).option("--only <service>", "with several services in kvbox.json: deploy this one only (repeatable)", (v, all) => [...all ?? [], v]).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) => {
7835
+ var deployCommand = new Command67("deploy").description("put the app in this directory (React, Next.js, a Node server, a Dockerfile or a static site) on a box with its own HTTPS address; redeploy by running it again").argument("[dir]", "the app's directory (default: the current one)").addOption(new Option5("-t, --template <template>", "what kind of app it is (detected from package.json and the directory when not given)").choices(TEMPLATE_IDS)).option("-n, --name <name>", "the box's name (default: the directory's name)").option("--sub <subdomain>", "its HTTPS name, https://<subdomain>.kvbox.app (default: the box's name)").addOption(new Option5("-s, --size <size>", "size of the box when it has to be made").choices(SIZE_NAMES)).option("--port <port>", "the box port of a Next.js app, Node server or container (default 3000; saved to kvbox.json)", parsePort).option("--only <service>", "with several services in kvbox.json: deploy this one only (repeatable)", (v, all) => [...all ?? [], v]).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) => {
7649
7836
  const dir = resolve3(dirArg ?? ".");
7650
7837
  const pkg = await readPackageJson2(dir);
7651
7838
  const facts = { indexHtml: await exists2(resolve3(dir, "index.html")), dockerfile: await exists2(resolve3(dir, "Dockerfile")) };
@@ -7802,15 +7989,15 @@ async function settle2(dir, pkg, facts, saved, opts, orgFlag, cloud) {
7802
7989
  }
7803
7990
 
7804
7991
  // src/commands/volume/index.ts
7805
- import { Command as Command78 } from "commander";
7992
+ import { Command as Command80 } from "commander";
7806
7993
 
7807
7994
  // src/commands/volume/attach.ts
7808
- import { Command as Command66 } from "commander";
7995
+ import { Command as Command68 } from "commander";
7809
7996
  function describeMount(machine, volume2, box2) {
7810
7997
  const path = machine.volumes?.find((v) => volume2 === v.name || volume2.endsWith(`/${v.name}`))?.mountPath ?? volumeMountPath(volume2.slice(volume2.lastIndexOf("/") + 1));
7811
7998
  return machine.status === "running" ? ` the box was restarted; the volume is at ${path} inside it` : ` box ${box2} is ${machine.status}; the volume is at ${path} once it runs`;
7812
7999
  }
7813
- var attachCommand = new Command66("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) => {
8000
+ var attachCommand = new Command68("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) => {
7814
8001
  if (volumeArg === void 0 || boxArg === void 0) askOrUsage("give the volume and the box: kvbox volume attach <volume> <box>");
7815
8002
  const client = await clientFor(cmd.optsWithGlobals());
7816
8003
  try {
@@ -7829,11 +8016,11 @@ var attachCommand = new Command66("attach").description("attach a volume to a bo
7829
8016
  });
7830
8017
 
7831
8018
  // src/commands/volume/backup/index.ts
7832
- import { Command as Command72 } from "commander";
8019
+ import { Command as Command74 } from "commander";
7833
8020
 
7834
8021
  // src/commands/volume/backup/create.ts
7835
- import { Command as Command67 } from "commander";
7836
- var createCommand4 = new Command67("create").description("back up a volume's disk to the kvbox cloud (encrypted)").argument("<volume>", "volume name").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (volume2, opts, cmd) => {
8022
+ import { Command as Command69 } from "commander";
8023
+ var createCommand4 = new Command69("create").description("back up a volume's disk to the kvbox cloud (encrypted)").argument("<volume>", "volume name").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (volume2, opts, cmd) => {
7837
8024
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7838
8025
  try {
7839
8026
  requireCloud3(client);
@@ -7860,8 +8047,8 @@ var createCommand4 = new Command67("create").description("back up a volume's dis
7860
8047
  });
7861
8048
 
7862
8049
  // src/commands/volume/backup/ls.ts
7863
- import { Command as Command68 } from "commander";
7864
- var lsCommand10 = new Command68("ls").alias("list").description("list volume backups: every volume's, or one volume's").argument("[volume]", "volume name (default: every volume)").option("--json", "print as JSON").action(async (volume2, opts, cmd) => {
8050
+ import { Command as Command70 } from "commander";
8051
+ var lsCommand10 = new Command70("ls").alias("list").description("list volume backups: every volume's, or one volume's").argument("[volume]", "volume name (default: every volume)").option("--json", "print as JSON").action(async (volume2, opts, cmd) => {
7865
8052
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7866
8053
  try {
7867
8054
  requireCloud3(client);
@@ -7894,8 +8081,8 @@ var lsCommand10 = new Command68("ls").alias("list").description("list volume bac
7894
8081
  });
7895
8082
 
7896
8083
  // src/commands/volume/backup/restore.ts
7897
- import { Command as Command69 } from "commander";
7898
- var restoreCommand2 = new Command69("restore").description("put a backup back: the volume's data becomes the backup's (a running box holding it restarts)").argument("<volume>", "volume name").argument("<id>", "the backup's id (kvbox volume backup ls <volume>)").option("-y, --yes", "do not ask for confirmation").option("--json", "print the volume as JSON").action(async (volume2, id, opts, cmd) => {
8084
+ import { Command as Command71 } from "commander";
8085
+ var restoreCommand2 = new Command71("restore").description("put a backup back: the volume's data becomes the backup's (a running box holding it restarts)").argument("<volume>", "volume name").argument("<id>", "the backup's id (kvbox volume backup ls <volume>)").option("-y, --yes", "do not ask for confirmation").option("--json", "print the volume as JSON").action(async (volume2, id, opts, cmd) => {
7899
8086
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7900
8087
  try {
7901
8088
  requireCloud3(client);
@@ -7918,8 +8105,8 @@ var restoreCommand2 = new Command69("restore").description("put a backup back: t
7918
8105
  });
7919
8106
 
7920
8107
  // src/commands/volume/backup/rm.ts
7921
- import { Command as Command70 } from "commander";
7922
- var rmCommand9 = new Command70("rm").alias("remove").description("remove a backup for good (a volume's that is gone too)").argument("<volume>", "volume name").argument("<id>", "the backup's id (kvbox volume backup ls <volume>)").option("-y, --yes", "do not ask for confirmation").action(async (volume2, id, opts, cmd) => {
8108
+ import { Command as Command72 } from "commander";
8109
+ var rmCommand9 = new Command72("rm").alias("remove").description("remove a backup for good (a volume's that is gone too)").argument("<volume>", "volume name").argument("<id>", "the backup's id (kvbox volume backup ls <volume>)").option("-y, --yes", "do not ask for confirmation").action(async (volume2, id, opts, cmd) => {
7923
8110
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7924
8111
  try {
7925
8112
  requireCloud3(client);
@@ -7930,9 +8117,9 @@ var rmCommand9 = new Command70("rm").alias("remove").description("remove a backu
7930
8117
  });
7931
8118
 
7932
8119
  // src/commands/volume/backup/schedule.ts
7933
- import { Command as Command71 } from "commander";
8120
+ import { Command as Command73 } from "commander";
7934
8121
  var scheduleCommand2 = scheduleFlags(
7935
- new Command71("schedule").description("show or switch a volume's nightly backup (daily, UTC; off until you turn it on)").argument("<volume>", "volume name")
8122
+ new Command73("schedule").description("show or switch a volume's nightly backup (daily, UTC; off until you turn it on)").argument("<volume>", "volume name")
7936
8123
  ).action(async (volume2, flags, cmd) => {
7937
8124
  const change = changeOf(flags);
7938
8125
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
@@ -7948,15 +8135,15 @@ var scheduleCommand2 = scheduleFlags(
7948
8135
  });
7949
8136
 
7950
8137
  // src/commands/volume/backup/index.ts
7951
- var backupCommand2 = new Command72("backup").description("back up a volume's disk to the kvbox cloud, list backups, restore or remove one").addCommand(createCommand4).addCommand(lsCommand10).addCommand(restoreCommand2).addCommand(rmCommand9).addCommand(scheduleCommand2);
8138
+ var backupCommand2 = new Command74("backup").description("back up a volume's disk to the kvbox cloud, list backups, restore or remove one").addCommand(createCommand4).addCommand(lsCommand10).addCommand(restoreCommand2).addCommand(rmCommand9).addCommand(scheduleCommand2);
7952
8139
  for (const cmd of backupCommand2.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
7953
8140
 
7954
8141
  // src/commands/volume/create.ts
7955
- import { Command as Command73 } from "commander";
8142
+ import { Command as Command75 } from "commander";
7956
8143
  function parseGib2(text2, label = "--size") {
7957
- const mib = parseMib(text2);
7958
- if (mib === void 0 || mib % 1024 !== 0) throw new KvboxError(`${label} ${text2}: write whole GB, like 50 or 50GB`);
7959
- const gib = mib / 1024;
8144
+ const mib2 = parseMib(text2);
8145
+ if (mib2 === void 0 || mib2 % 1024 !== 0) throw new KvboxError(`${label} ${text2}: write whole GB, like 50 or 50GB`);
8146
+ const gib = mib2 / 1024;
7960
8147
  if (gib > MAX_VOLUME_GIB) throw new KvboxError(`${label} ${text2}: a volume is at most ${MAX_VOLUME_GIB} GB`);
7961
8148
  return gib;
7962
8149
  }
@@ -7968,7 +8155,7 @@ function sizeProblem(answer) {
7968
8155
  return err instanceof KvboxError ? err.message.replace(/^--size \S+: /, "") : String(err);
7969
8156
  }
7970
8157
  }
7971
- var createCommand5 = new Command73("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) => {
8158
+ var createCommand5 = new Command75("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) => {
7972
8159
  const ask = interactive();
7973
8160
  if (nameArg === void 0 || opts.size === void 0) askOrUsage("give the name and the size: kvbox volume create <name> --size <gb> --box <box>");
7974
8161
  const name = nameArg ?? await text("Volume name", { validate: (a) => VOLUME_NAME_RE.test(a) ? void 0 : VOLUME_NAME_RULE });
@@ -8001,8 +8188,8 @@ var createCommand5 = new Command73("create").alias("new").description("create a
8001
8188
  });
8002
8189
 
8003
8190
  // src/commands/volume/detach.ts
8004
- import { Command as Command74 } from "commander";
8005
- var detachCommand = new Command74("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) => {
8191
+ import { Command as Command76 } from "commander";
8192
+ var detachCommand = new Command76("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) => {
8006
8193
  if (volumeArg === void 0) askOrUsage("give the volume: kvbox volume detach <volume> [box]");
8007
8194
  const client = await clientFor(cmd.optsWithGlobals());
8008
8195
  try {
@@ -8027,8 +8214,8 @@ var detachCommand = new Command74("detach").description("detach a volume from a
8027
8214
  });
8028
8215
 
8029
8216
  // src/commands/volume/grow.ts
8030
- import { Command as Command75 } from "commander";
8031
- var growCommand = new Command75("grow").alias("resize").description("make a volume larger (a running box holding it is restarted once)").argument("<volume>", "volume name").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print the volume as JSON").action(async (name, size, opts, cmd) => {
8217
+ import { Command as Command77 } from "commander";
8218
+ var growCommand = new Command77("grow").alias("resize").description("make a volume larger (a running box holding it is restarted once)").argument("<volume>", "volume name").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print the volume as JSON").action(async (name, size, opts, cmd) => {
8032
8219
  const sizeGib = parseGib2(size, "size");
8033
8220
  const client = await clientFor(cmd.optsWithGlobals());
8034
8221
  try {
@@ -8041,8 +8228,8 @@ var growCommand = new Command75("grow").alias("resize").description("make a volu
8041
8228
  });
8042
8229
 
8043
8230
  // src/commands/volume/ls.ts
8044
- import { Command as Command76 } from "commander";
8045
- var lsCommand11 = new Command76("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) => {
8231
+ import { Command as Command78 } from "commander";
8232
+ var lsCommand11 = new Command78("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) => {
8046
8233
  const client = await clientFor(cmd.optsWithGlobals());
8047
8234
  try {
8048
8235
  const cloud = client.target.kind === "cloud";
@@ -8073,8 +8260,8 @@ var lsCommand11 = new Command76("ls").alias("list").description("list volumes: s
8073
8260
  });
8074
8261
 
8075
8262
  // src/commands/volume/rm.ts
8076
- import { Command as Command77 } from "commander";
8077
- var rmCommand10 = new Command77("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) => {
8263
+ import { Command as Command79 } from "commander";
8264
+ var rmCommand10 = new Command79("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) => {
8078
8265
  if (!await confirm(`Delete volume ${name} and everything on it?`, opts.yes ?? false)) {
8079
8266
  info("cancelled");
8080
8267
  process.exitCode = 1;
@@ -8090,18 +8277,18 @@ var rmCommand10 = new Command77("rm").alias("remove").description("delete a volu
8090
8277
  });
8091
8278
 
8092
8279
  // src/commands/volume/index.ts
8093
- var volumeCommand = new Command78("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(createCommand5).addCommand(lsCommand11).addCommand(attachCommand).addCommand(detachCommand).addCommand(growCommand).addCommand(rmCommand10);
8280
+ var volumeCommand = new Command80("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(createCommand5).addCommand(lsCommand11).addCommand(attachCommand).addCommand(detachCommand).addCommand(growCommand).addCommand(rmCommand10);
8094
8281
  for (const cmd of volumeCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
8095
8282
  volumeCommand.addCommand(backupCommand2);
8096
8283
 
8097
8284
  // src/commands/bucket/index.ts
8098
- import { Command as Command95 } from "commander";
8285
+ import { Command as Command97 } from "commander";
8099
8286
 
8100
8287
  // src/commands/bucket/backup/index.ts
8101
- import { Command as Command84 } from "commander";
8288
+ import { Command as Command86 } from "commander";
8102
8289
 
8103
8290
  // src/commands/bucket/backup/create.ts
8104
- import { Command as Command79 } from "commander";
8291
+ import { Command as Command81 } from "commander";
8105
8292
 
8106
8293
  // src/commands/bucket/shared.ts
8107
8294
  async function bucketClient(cmd) {
@@ -8127,7 +8314,7 @@ function printRows(rows2) {
8127
8314
  }
8128
8315
 
8129
8316
  // src/commands/bucket/backup/create.ts
8130
- var createCommand6 = new Command79("create").description("back up your object storage (every bucket and key) to the kvbox cloud, encrypted").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (opts, cmd) => {
8317
+ var createCommand6 = new Command81("create").description("back up your object storage (every bucket and key) to the kvbox cloud, encrypted").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (opts, cmd) => {
8131
8318
  const client = await bucketClient(cmd);
8132
8319
  const ls = "kvbox bucket backup ls";
8133
8320
  try {
@@ -8155,8 +8342,8 @@ var createCommand6 = new Command79("create").description("back up your object st
8155
8342
  });
8156
8343
 
8157
8344
  // src/commands/bucket/backup/ls.ts
8158
- import { Command as Command80 } from "commander";
8159
- var lsCommand12 = new Command80("ls").alias("list").description("list the backups of your object storage").option("--json", "print as JSON").action(async (opts, cmd) => {
8345
+ import { Command as Command82 } from "commander";
8346
+ var lsCommand12 = new Command82("ls").alias("list").description("list the backups of your object storage").option("--json", "print as JSON").action(async (opts, cmd) => {
8160
8347
  const client = await bucketClient(cmd);
8161
8348
  try {
8162
8349
  const list = await client.storageBackups();
@@ -8188,8 +8375,8 @@ var lsCommand12 = new Command80("ls").alias("list").description("list the backup
8188
8375
  });
8189
8376
 
8190
8377
  // src/commands/bucket/backup/restore.ts
8191
- import { Command as Command81 } from "commander";
8192
- var restoreCommand3 = new Command81("restore").description("put a backup back: every bucket and key becomes the backup's (the storage restarts)").argument("<id>", "the backup's id (kvbox bucket backup ls)").option("-y, --yes", "do not ask for confirmation").option("--json", "print what changed as JSON").action(async (id, opts, cmd) => {
8378
+ import { Command as Command83 } from "commander";
8379
+ var restoreCommand3 = new Command83("restore").description("put a backup back: every bucket and key becomes the backup's (the storage restarts)").argument("<id>", "the backup's id (kvbox bucket backup ls)").option("-y, --yes", "do not ask for confirmation").option("--json", "print what changed as JSON").action(async (id, opts, cmd) => {
8193
8380
  const client = await bucketClient(cmd);
8194
8381
  try {
8195
8382
  const backup = await client.storageBackup(id);
@@ -8219,8 +8406,8 @@ var restoreCommand3 = new Command81("restore").description("put a backup back: e
8219
8406
  });
8220
8407
 
8221
8408
  // src/commands/bucket/backup/rm.ts
8222
- import { Command as Command82 } from "commander";
8223
- var rmCommand11 = new Command82("rm").alias("remove").description("remove a backup of your object storage for good").argument("<id>", "the backup's id (kvbox bucket backup ls)").option("-y, --yes", "do not ask for confirmation").action(async (id, opts, cmd) => {
8409
+ import { Command as Command84 } from "commander";
8410
+ var rmCommand11 = new Command84("rm").alias("remove").description("remove a backup of your object storage for good").argument("<id>", "the backup's id (kvbox bucket backup ls)").option("-y, --yes", "do not ask for confirmation").action(async (id, opts, cmd) => {
8224
8411
  const client = await bucketClient(cmd);
8225
8412
  try {
8226
8413
  const backup = (await client.storageBackups()).find((b) => b.id === id);
@@ -8239,8 +8426,8 @@ var rmCommand11 = new Command82("rm").alias("remove").description("remove a back
8239
8426
  });
8240
8427
 
8241
8428
  // src/commands/bucket/backup/schedule.ts
8242
- import { Command as Command83 } from "commander";
8243
- var scheduleCommand3 = scheduleFlags(new Command83("schedule").description("show or switch the nightly backup of your object storage (daily, UTC; off until you turn it on)")).action(
8429
+ import { Command as Command85 } from "commander";
8430
+ var scheduleCommand3 = scheduleFlags(new Command85("schedule").description("show or switch the nightly backup of your object storage (daily, UTC; off until you turn it on)")).action(
8244
8431
  async (flags, cmd) => {
8245
8432
  const change = changeOf(flags);
8246
8433
  const client = await bucketClient(cmd);
@@ -8256,11 +8443,11 @@ var scheduleCommand3 = scheduleFlags(new Command83("schedule").description("show
8256
8443
  );
8257
8444
 
8258
8445
  // src/commands/bucket/backup/index.ts
8259
- var backupCommand3 = new Command84("backup").aliases(["backups"]).description("back up your object storage to the kvbox cloud, list backups, restore or remove one").addCommand(createCommand6).addCommand(lsCommand12).addCommand(restoreCommand3).addCommand(rmCommand11).addCommand(scheduleCommand3);
8446
+ var backupCommand3 = new Command86("backup").aliases(["backups"]).description("back up your object storage to the kvbox cloud, list backups, restore or remove one").addCommand(createCommand6).addCommand(lsCommand12).addCommand(restoreCommand3).addCommand(rmCommand11).addCommand(scheduleCommand3);
8260
8447
 
8261
8448
  // src/commands/bucket/create.ts
8262
- import { Command as Command85 } from "commander";
8263
- var createCommand7 = new Command85("create").description("make a bucket (the first one also makes your object storage)").argument("<name>", "bucket name: 3-63 lowercase letters, digits and '-'").option("--size <GB>", "how much your object storage may hold, when this is your first bucket (default 10)").option("--region <region>", "the S3 region of your object storage (ro-west-1, de-center-1), when this is your first bucket").option("--near <box>", "put the object storage on the host of this box, when this is your first bucket").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8449
+ import { Command as Command87 } from "commander";
8450
+ var createCommand7 = new Command87("create").description("make a bucket (the first one also makes your object storage)").argument("<name>", "bucket name: 3-63 lowercase letters, digits and '-'").option("--size <GB>", "how much your object storage may hold, when this is your first bucket (default 10)").option("--region <region>", "the S3 region of your object storage (ro-west-1, de-center-1), when this is your first bucket").option("--near <box>", "put the object storage on the host of this box, when this is your first bucket").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8264
8451
  const sizeGib = opts.size === void 0 ? void 0 : parseGib2(opts.size);
8265
8452
  const client = await bucketClient(cmd);
8266
8453
  try {
@@ -8280,8 +8467,8 @@ var createCommand7 = new Command85("create").description("make a bucket (the fir
8280
8467
  });
8281
8468
 
8282
8469
  // src/commands/bucket/grow.ts
8283
- import { Command as Command86 } from "commander";
8284
- var growCommand2 = new Command86("grow").description("make your object storage larger (all your buckets share it; it restarts once)").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print the object storage as JSON").action(async (size, opts, cmd) => {
8470
+ import { Command as Command88 } from "commander";
8471
+ var growCommand2 = new Command88("grow").description("make your object storage larger (all your buckets share it; it restarts once)").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print the object storage as JSON").action(async (size, opts, cmd) => {
8285
8472
  const sizeGib = parseGib2(size, "size");
8286
8473
  const client = await bucketClient(cmd);
8287
8474
  try {
@@ -8294,8 +8481,8 @@ var growCommand2 = new Command86("grow").description("make your object storage l
8294
8481
  });
8295
8482
 
8296
8483
  // src/commands/bucket/info.ts
8297
- import { Command as Command87 } from "commander";
8298
- var infoCommand = new Command87("info").description("one bucket: its address, what it holds, how full your object storage is").argument("<name>", "bucket name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8484
+ import { Command as Command89 } from "commander";
8485
+ var infoCommand = new Command89("info").description("one bucket: its address, what it holds, how full your object storage is").argument("<name>", "bucket name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8299
8486
  const client = await bucketClient(cmd);
8300
8487
  try {
8301
8488
  const b = await client.getBucket(name);
@@ -8325,11 +8512,11 @@ with the AWS CLI: aws s3 ls s3://${b.name} --endpoint-url ${b.endpoint}`));
8325
8512
  });
8326
8513
 
8327
8514
  // src/commands/bucket/key/index.ts
8328
- import { Command as Command91 } from "commander";
8515
+ import { Command as Command93 } from "commander";
8329
8516
 
8330
8517
  // src/commands/bucket/key/create.ts
8331
- import { Command as Command88 } from "commander";
8332
- var createCommand8 = new Command88("create").description("make an access key for a bucket (the secret is shown once)").argument("<bucket>", "bucket name").option("--name <label>", "what to call the key, to tell it from the others").option("--read-only", "the key reads the bucket but cannot write to it").option("--json", "print as JSON").action(async (bucket, opts, cmd) => {
8518
+ import { Command as Command90 } from "commander";
8519
+ var createCommand8 = new Command90("create").description("make an access key for a bucket (the secret is shown once)").argument("<bucket>", "bucket name").option("--name <label>", "what to call the key, to tell it from the others").option("--read-only", "the key reads the bucket but cannot write to it").option("--json", "print as JSON").action(async (bucket, opts, cmd) => {
8333
8520
  const client = await bucketClient(cmd);
8334
8521
  try {
8335
8522
  const key = await client.createBucketKey(bucket, { ...opts.name !== void 0 ? { name: opts.name } : {}, ...opts.readOnly ? { readOnly: true } : {} });
@@ -8352,8 +8539,8 @@ var createCommand8 = new Command88("create").description("make an access key for
8352
8539
  });
8353
8540
 
8354
8541
  // src/commands/bucket/key/ls.ts
8355
- import { Command as Command89 } from "commander";
8356
- var lsCommand13 = new Command89("ls").alias("list").description("list a bucket's access keys (never their secrets)").argument("<bucket>", "bucket name").option("--json", "print as JSON").action(async (bucket, opts, cmd) => {
8542
+ import { Command as Command91 } from "commander";
8543
+ var lsCommand13 = new Command91("ls").alias("list").description("list a bucket's access keys (never their secrets)").argument("<bucket>", "bucket name").option("--json", "print as JSON").action(async (bucket, opts, cmd) => {
8357
8544
  const client = await bucketClient(cmd);
8358
8545
  try {
8359
8546
  const keys = await client.listBucketKeys(bucket);
@@ -8372,8 +8559,8 @@ var lsCommand13 = new Command89("ls").alias("list").description("list a bucket's
8372
8559
  });
8373
8560
 
8374
8561
  // src/commands/bucket/key/rm.ts
8375
- import { Command as Command90 } from "commander";
8376
- var rmCommand12 = new Command90("rm").alias("remove").description("delete an access key: whatever uses it stops reaching the bucket").argument("<bucket>", "bucket name").argument("<access-key>", "the access key id (kvbox bucket key ls)").option("-y, --yes", "do not ask for confirmation").action(async (bucket, id, opts, cmd) => {
8562
+ import { Command as Command92 } from "commander";
8563
+ var rmCommand12 = new Command92("rm").alias("remove").description("delete an access key: whatever uses it stops reaching the bucket").argument("<bucket>", "bucket name").argument("<access-key>", "the access key id (kvbox bucket key ls)").option("-y, --yes", "do not ask for confirmation").action(async (bucket, id, opts, cmd) => {
8377
8564
  const client = await bucketClient(cmd);
8378
8565
  try {
8379
8566
  if (!await confirm(`Delete key ${id} of bucket ${bucket}? Whatever uses it stops working.`, opts.yes ?? false)) {
@@ -8389,11 +8576,11 @@ var rmCommand12 = new Command90("rm").alias("remove").description("delete an acc
8389
8576
  });
8390
8577
 
8391
8578
  // src/commands/bucket/key/index.ts
8392
- var keyCommand2 = new Command91("key").aliases(["keys"]).description("access keys of a bucket: what your app signs in with").addCommand(createCommand8).addCommand(lsCommand13).addCommand(rmCommand12);
8579
+ var keyCommand2 = new Command93("key").aliases(["keys"]).description("access keys of a bucket: what your app signs in with").addCommand(createCommand8).addCommand(lsCommand13).addCommand(rmCommand12);
8393
8580
 
8394
8581
  // src/commands/bucket/ls.ts
8395
- import { Command as Command92 } from "commander";
8396
- var lsCommand14 = new Command92("ls").alias("list").description("list buckets, and the object storage they are in").option("-a, --all", "every bucket on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
8582
+ import { Command as Command94 } from "commander";
8583
+ var lsCommand14 = new Command94("ls").alias("list").description("list buckets, and the object storage they are in").option("-a, --all", "every bucket on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
8397
8584
  const client = await bucketClient(cmd);
8398
8585
  try {
8399
8586
  const buckets = await client.listBuckets({ all: opts.all });
@@ -8424,8 +8611,8 @@ var lsCommand14 = new Command92("ls").alias("list").description("list buckets, a
8424
8611
  });
8425
8612
 
8426
8613
  // src/commands/bucket/public.ts
8427
- import { Command as Command93 } from "commander";
8428
- var publicCommand = new Command93("public").description("let anyone read a bucket's files at its own HTTPS address (on), or make it private again (off)").argument("<name>", "bucket name").argument("<state>", "on (public) or off (private)").option("--sub <name>", "the address to use, <name>.kvbox.app (default: <bucket>-<account>)").option("--json", "print the bucket as JSON").action(async (name, state, opts, cmd) => {
8614
+ import { Command as Command95 } from "commander";
8615
+ var publicCommand = new Command95("public").description("let anyone read a bucket's files at its own HTTPS address (on), or make it private again (off)").argument("<name>", "bucket name").argument("<state>", "on (public) or off (private)").option("--sub <name>", "the address to use, <name>.kvbox.app (default: <bucket>-<account>)").option("--json", "print the bucket as JSON").action(async (name, state, opts, cmd) => {
8429
8616
  if (state !== "on" && state !== "off") throw new KvboxError(`"${state}": say on or off`);
8430
8617
  const on = state === "on";
8431
8618
  if (!on && opts.sub !== void 0) throw new KvboxError("--sub goes with on");
@@ -8453,8 +8640,8 @@ var publicCommand = new Command93("public").description("let anyone read a bucke
8453
8640
  });
8454
8641
 
8455
8642
  // src/commands/bucket/rm.ts
8456
- import { Command as Command94 } from "commander";
8457
- var rmCommand13 = new Command94("rm").alias("remove").description("delete an empty bucket and its keys (the last one takes your object storage with it)").argument("<name>", "bucket name").option("--force", "your last bucket only: delete it with everything in it").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
8643
+ import { Command as Command96 } from "commander";
8644
+ var rmCommand13 = new Command96("rm").alias("remove").description("delete an empty bucket and its keys (the last one takes your object storage with it)").argument("<name>", "bucket name").option("--force", "your last bucket only: delete it with everything in it").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
8458
8645
  const client = await bucketClient(cmd);
8459
8646
  try {
8460
8647
  const question = opts.force ? `Delete bucket ${name} with everything in it, and the object storage it is in?` : `Delete bucket ${name} and its keys?`;
@@ -8473,7 +8660,7 @@ var rmCommand13 = new Command94("rm").alias("remove").description("delete an emp
8473
8660
  });
8474
8661
 
8475
8662
  // src/commands/bucket/index.ts
8476
- var bucketCommand = new Command95("bucket").aliases(["buckets"]).description("object storage: S3 buckets for your files, and the access keys your apps use").addCommand(createCommand7).addCommand(lsCommand14).addCommand(infoCommand).addCommand(growCommand2).addCommand(publicCommand).addCommand(rmCommand13).addCommand(keyCommand2).addCommand(backupCommand3);
8663
+ var bucketCommand = new Command97("bucket").aliases(["buckets"]).description("object storage: S3 buckets for your files, and the access keys your apps use").addCommand(createCommand7).addCommand(lsCommand14).addCommand(infoCommand).addCommand(growCommand2).addCommand(publicCommand).addCommand(rmCommand13).addCommand(keyCommand2).addCommand(backupCommand3);
8477
8664
  var withOrg2 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal buckets)");
8478
8665
  for (const cmd of bucketCommand.commands) {
8479
8666
  if (cmd === keyCommand2 || cmd === backupCommand3) cmd.commands.forEach(withOrg2);
@@ -8481,10 +8668,10 @@ for (const cmd of bucketCommand.commands) {
8481
8668
  }
8482
8669
 
8483
8670
  // src/commands/cron/index.ts
8484
- import { Command as Command108 } from "commander";
8671
+ import { Command as Command110 } from "commander";
8485
8672
 
8486
8673
  // src/commands/cron/create.ts
8487
- import { Command as Command96 } from "commander";
8674
+ import { Command as Command98 } from "commander";
8488
8675
 
8489
8676
  // src/commands/cron/shared.ts
8490
8677
  async function cronClient(cmd) {
@@ -8545,7 +8732,7 @@ function printRows2(rows2) {
8545
8732
  var noTriggers = (service) => info(`cron service ${service} has no triggers yet; add one with: kvbox cron trigger add ${service} <box> "0 6 * * *" --port 3000 (or --run "<command>")`);
8546
8733
 
8547
8734
  // src/commands/cron/create.ts
8548
- var createCommand9 = new Command96("create").description("make a cron service: a named set of triggers").argument("<name>", "what to call it (lowercase letters, digits and '-')").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8735
+ var createCommand9 = new Command98("create").description("make a cron service: a named set of triggers").argument("<name>", "what to call it (lowercase letters, digits and '-')").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8549
8736
  const client = await cronClient(cmd);
8550
8737
  try {
8551
8738
  const service = await client.createCronService(name);
@@ -8562,8 +8749,8 @@ var createCommand9 = new Command96("create").description("make a cron service: a
8562
8749
  });
8563
8750
 
8564
8751
  // src/commands/cron/info.ts
8565
- import { Command as Command97 } from "commander";
8566
- var infoCommand2 = new Command97("info").alias("get").description("show a cron service and its triggers").argument("<name>", "cron service name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8752
+ import { Command as Command99 } from "commander";
8753
+ var infoCommand2 = new Command99("info").alias("get").description("show a cron service and its triggers").argument("<name>", "cron service name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8567
8754
  const client = await cronClient(cmd);
8568
8755
  try {
8569
8756
  const service = await client.getCronService(name);
@@ -8587,8 +8774,8 @@ var infoCommand2 = new Command97("info").alias("get").description("show a cron s
8587
8774
  });
8588
8775
 
8589
8776
  // src/commands/cron/ls.ts
8590
- import { Command as Command98 } from "commander";
8591
- var lsCommand15 = new Command98("ls").alias("list").description("list cron services").option("-a, --all", "every cron service on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
8777
+ import { Command as Command100 } from "commander";
8778
+ var lsCommand15 = new Command100("ls").alias("list").description("list cron services").option("-a, --all", "every cron service on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
8592
8779
  const client = await cronClient(cmd);
8593
8780
  try {
8594
8781
  const services = await client.listCronServices({ all: opts.all });
@@ -8608,8 +8795,8 @@ var lsCommand15 = new Command98("ls").alias("list").description("list cron servi
8608
8795
  });
8609
8796
 
8610
8797
  // src/commands/cron/rm.ts
8611
- import { Command as Command99 } from "commander";
8612
- var rmCommand14 = new Command99("rm").alias("remove").description("delete a cron service, its triggers and their run history").argument("<name>", "cron service name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
8798
+ import { Command as Command101 } from "commander";
8799
+ var rmCommand14 = new Command101("rm").alias("remove").description("delete a cron service, its triggers and their run history").argument("<name>", "cron service name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
8613
8800
  const client = await cronClient(cmd);
8614
8801
  try {
8615
8802
  if (!await confirm(`Delete cron service ${name}? Its triggers stop firing and their run history is deleted.`, opts.yes ?? false)) {
@@ -8625,10 +8812,10 @@ var rmCommand14 = new Command99("rm").alias("remove").description("delete a cron
8625
8812
  });
8626
8813
 
8627
8814
  // src/commands/cron/trigger/index.ts
8628
- import { Command as Command107 } from "commander";
8815
+ import { Command as Command109 } from "commander";
8629
8816
 
8630
8817
  // src/commands/cron/trigger/add.ts
8631
- import { Command as Command100 } from "commander";
8818
+ import { Command as Command102 } from "commander";
8632
8819
  function portOf(value) {
8633
8820
  const n2 = Number(value);
8634
8821
  if (!Number.isInteger(n2) || n2 < 1 || n2 > 65535) throw new KvboxError(`--port ${value}: a port is a number from 1 to 65535`);
@@ -8648,7 +8835,7 @@ function timeoutOf(value) {
8648
8835
  if (sec > MAX_CRON_COMMAND_TIMEOUT_SEC) throw new KvboxError(`--timeout ${value}: a command may run for ${MAX_CRON_COMMAND_TIMEOUT_SEC / 60} minutes at most`);
8649
8836
  return sec;
8650
8837
  }
8651
- var addCommand3 = new Command100("add").description("add a trigger: on a schedule, call a port of a box or run a command in it").argument("<service>", "cron service name").argument("<box>", "the box it acts on").argument("<expr>", 'cron expression in quotes, five fields: "0 6 * * *" is every day at 06:00').option("--port <n>", "call this port, the one your app listens on in the box").option("--path <path>", "with --port: path and query to request (default: /)").option("--method <method>", `with --port: HTTP method, ${CRON_METHODS.join(" or ")} (default: POST)`).option("--run <command>", 'or run this command in the box, in quotes: "node ~/app/embed.js"').option("--timeout <duration>", `with --run: stop the command after this long (90s, 10m, 1h; default: ${DEFAULT_CRON_COMMAND_TIMEOUT_SEC / 60}m)`).option("--tz <zone>", "time zone the schedule is read in, like Europe/Bucharest", "UTC").option("--json", "print as JSON").action(async (service, box2, expr, opts, cmd) => {
8838
+ var addCommand3 = new Command102("add").description("add a trigger: on a schedule, call a port of a box or run a command in it").argument("<service>", "cron service name").argument("<box>", "the box it acts on").argument("<expr>", 'cron expression in quotes, five fields: "0 6 * * *" is every day at 06:00').option("--port <n>", "call this port, the one your app listens on in the box").option("--path <path>", "with --port: path and query to request (default: /)").option("--method <method>", `with --port: HTTP method, ${CRON_METHODS.join(" or ")} (default: POST)`).option("--run <command>", 'or run this command in the box, in quotes: "node ~/app/embed.js"').option("--timeout <duration>", `with --run: stop the command after this long (90s, 10m, 1h; default: ${DEFAULT_CRON_COMMAND_TIMEOUT_SEC / 60}m)`).option("--tz <zone>", "time zone the schedule is read in, like Europe/Bucharest", "UTC").option("--json", "print as JSON").action(async (service, box2, expr, opts, cmd) => {
8652
8839
  let action;
8653
8840
  if (opts.run !== void 0) {
8654
8841
  if (opts.port !== void 0 || opts.path !== void 0 || opts.method !== void 0) throw new KvboxError("a trigger runs a command or calls a port: use --run, or --port with --path and --method, not both");
@@ -8675,8 +8862,8 @@ var addCommand3 = new Command100("add").description("add a trigger: on a schedul
8675
8862
  });
8676
8863
 
8677
8864
  // src/commands/cron/trigger/ls.ts
8678
- import { Command as Command101 } from "commander";
8679
- var lsCommand16 = new Command101("ls").alias("list").description("list a cron service's triggers").argument("<service>", "cron service name").option("--json", "print as JSON").action(async (service, opts, cmd) => {
8865
+ import { Command as Command103 } from "commander";
8866
+ var lsCommand16 = new Command103("ls").alias("list").description("list a cron service's triggers").argument("<service>", "cron service name").option("--json", "print as JSON").action(async (service, opts, cmd) => {
8680
8867
  const client = await cronClient(cmd);
8681
8868
  try {
8682
8869
  const triggers = await client.listCronTriggers(service);
@@ -8692,8 +8879,8 @@ var lsCommand16 = new Command101("ls").alias("list").description("list a cron se
8692
8879
  });
8693
8880
 
8694
8881
  // src/commands/cron/trigger/pause.ts
8695
- import { Command as Command102 } from "commander";
8696
- var pauseCommand2 = new Command102("pause").description("stop a trigger from firing until it is resumed").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
8882
+ import { Command as Command104 } from "commander";
8883
+ var pauseCommand2 = new Command104("pause").description("stop a trigger from firing until it is resumed").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
8697
8884
  const client = await cronClient(cmd);
8698
8885
  try {
8699
8886
  const trigger = await client.setCronTriggerEnabled(service, id, false);
@@ -8708,8 +8895,8 @@ var pauseCommand2 = new Command102("pause").description("stop a trigger from fir
8708
8895
  });
8709
8896
 
8710
8897
  // src/commands/cron/trigger/resume.ts
8711
- import { Command as Command103 } from "commander";
8712
- var resumeCommand2 = new Command103("resume").description("let a paused trigger fire again").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
8898
+ import { Command as Command105 } from "commander";
8899
+ var resumeCommand2 = new Command105("resume").description("let a paused trigger fire again").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
8713
8900
  const client = await cronClient(cmd);
8714
8901
  try {
8715
8902
  const trigger = await client.setCronTriggerEnabled(service, id, true);
@@ -8724,8 +8911,8 @@ var resumeCommand2 = new Command103("resume").description("let a paused trigger
8724
8911
  });
8725
8912
 
8726
8913
  // src/commands/cron/trigger/rm.ts
8727
- import { Command as Command104 } from "commander";
8728
- var rmCommand15 = new Command104("rm").alias("remove").description("delete a trigger and its run history").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("-y, --yes", "do not ask for confirmation").action(async (service, id, opts, cmd) => {
8914
+ import { Command as Command106 } from "commander";
8915
+ var rmCommand15 = new Command106("rm").alias("remove").description("delete a trigger and its run history").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("-y, --yes", "do not ask for confirmation").action(async (service, id, opts, cmd) => {
8729
8916
  const client = await cronClient(cmd);
8730
8917
  try {
8731
8918
  if (!await confirm(`Delete trigger ${id} of cron service ${service}? Its run history is deleted too.`, opts.yes ?? false)) {
@@ -8741,8 +8928,8 @@ var rmCommand15 = new Command104("rm").alias("remove").description("delete a tri
8741
8928
  });
8742
8929
 
8743
8930
  // src/commands/cron/trigger/run.ts
8744
- import { Command as Command105 } from "commander";
8745
- var runCommand = new Command105("run").description("fire a trigger now, once, besides its schedule").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
8931
+ import { Command as Command107 } from "commander";
8932
+ var runCommand = new Command107("run").description("fire a trigger now, once, besides its schedule").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
8746
8933
  const client = await cronClient(cmd);
8747
8934
  try {
8748
8935
  const trigger = await client.runCronTrigger(service, id);
@@ -8758,13 +8945,13 @@ var runCommand = new Command105("run").description("fire a trigger now, once, be
8758
8945
  });
8759
8946
 
8760
8947
  // src/commands/cron/trigger/runs.ts
8761
- import { Command as Command106 } from "commander";
8948
+ import { Command as Command108 } from "commander";
8762
8949
  function limitOf(value) {
8763
8950
  const n2 = Number(value);
8764
8951
  if (!Number.isInteger(n2) || n2 < 1) throw new KvboxError(`-n ${value}: a number of runs, 1 or more`);
8765
8952
  return n2;
8766
8953
  }
8767
- var runsCommand = new Command106("runs").aliases(["logs"]).description("show how a trigger's last runs ended").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("-n, --limit <count>", "how many runs to show", "20").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
8954
+ var runsCommand = new Command108("runs").aliases(["logs"]).description("show how a trigger's last runs ended").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("-n, --limit <count>", "how many runs to show", "20").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
8768
8955
  const limit = limitOf(opts.limit);
8769
8956
  const client = await cronClient(cmd);
8770
8957
  try {
@@ -8794,10 +8981,10 @@ var runsCommand = new Command106("runs").aliases(["logs"]).description("show how
8794
8981
  });
8795
8982
 
8796
8983
  // src/commands/cron/trigger/index.ts
8797
- var triggerCommand = new Command107("trigger").aliases(["triggers"]).description("a cron service's triggers: a schedule and the request it sends to a box").addCommand(addCommand3).addCommand(lsCommand16).addCommand(runsCommand).addCommand(runCommand).addCommand(pauseCommand2).addCommand(resumeCommand2).addCommand(rmCommand15);
8984
+ var triggerCommand = new Command109("trigger").aliases(["triggers"]).description("a cron service's triggers: a schedule and the request it sends to a box").addCommand(addCommand3).addCommand(lsCommand16).addCommand(runsCommand).addCommand(runCommand).addCommand(pauseCommand2).addCommand(resumeCommand2).addCommand(rmCommand15);
8798
8985
 
8799
8986
  // src/commands/cron/index.ts
8800
- var cronCommand = new Command108("cron").description("cron: call a box on a schedule, waking it first if it sleeps").addCommand(createCommand9).addCommand(lsCommand15).addCommand(infoCommand2).addCommand(rmCommand14).addCommand(triggerCommand);
8987
+ var cronCommand = new Command110("cron").description("cron: call a box on a schedule, waking it first if it sleeps").addCommand(createCommand9).addCommand(lsCommand15).addCommand(infoCommand2).addCommand(rmCommand14).addCommand(triggerCommand);
8801
8988
  var withOrg3 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal cron services)");
8802
8989
  for (const cmd of cronCommand.commands) {
8803
8990
  if (cmd === triggerCommand) cmd.commands.forEach(withOrg3);
@@ -8805,13 +8992,13 @@ for (const cmd of cronCommand.commands) {
8805
8992
  }
8806
8993
 
8807
8994
  // src/commands/managed/kind.ts
8808
- import { Command as Command127 } from "commander";
8995
+ import { Command as Command129 } from "commander";
8809
8996
 
8810
8997
  // src/commands/managed/backup/index.ts
8811
- import { Command as Command115 } from "commander";
8998
+ import { Command as Command117 } from "commander";
8812
8999
 
8813
9000
  // src/commands/managed/backup/create.ts
8814
- import { Command as Command110 } from "commander";
9001
+ import { Command as Command112 } from "commander";
8815
9002
 
8816
9003
  // src/commands/managed/shared.ts
8817
9004
  import "commander";
@@ -8898,7 +9085,7 @@ function parseStorage(text2, flag) {
8898
9085
  }
8899
9086
 
8900
9087
  // src/commands/managed/backup/create.ts
8901
- var createCommand10 = (spec) => new Command110("create").description("back up a database to the kvbox cloud (encrypted)").argument("<db>", "its name").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (name, opts, cmd) => {
9088
+ var createCommand10 = (spec) => new Command112("create").description("back up a database to the kvbox cloud (encrypted)").argument("<db>", "its name").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (name, opts, cmd) => {
8902
9089
  const client = await managedClient(cmd);
8903
9090
  const ls = `kvbox ${spec.command} backup ls ${name}`;
8904
9091
  try {
@@ -8925,7 +9112,7 @@ var createCommand10 = (spec) => new Command110("create").description("back up a
8925
9112
  });
8926
9113
 
8927
9114
  // src/commands/managed/backup/ls.ts
8928
- import { Command as Command111 } from "commander";
9115
+ import { Command as Command113 } from "commander";
8929
9116
  var lsCommand17 = (spec) => {
8930
9117
  const removedOnes = async (err, name, client) => {
8931
9118
  if (!(err instanceof CallError && err.status === 404)) throw err;
@@ -8934,7 +9121,7 @@ var lsCommand17 = (spec) => {
8934
9121
  const own = name.includes("/") ? [] : gone.filter((b) => b.owner === me(client));
8935
9122
  return own.length > 0 ? own : gone;
8936
9123
  };
8937
- return new Command111("ls").alias("list").description("list backups: every database's, or one database's").argument("[db]", "its name (default: every database)").option("--json", "print as JSON").action(async (name, opts, cmd) => {
9124
+ return new Command113("ls").alias("list").description("list backups: every database's, or one database's").argument("[db]", "its name (default: every database)").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8938
9125
  const client = await managedClient(cmd);
8939
9126
  try {
8940
9127
  const list = name === void 0 ? await client.listManagedBackups(spec.kind) : await client.managedBackups(spec.kind, name).catch((err) => removedOnes(err, name, client));
@@ -8977,8 +9164,8 @@ var lsCommand17 = (spec) => {
8977
9164
  };
8978
9165
 
8979
9166
  // src/commands/managed/backup/restore.ts
8980
- import { Command as Command112 } from "commander";
8981
- var restoreCommand4 = (spec) => new Command112("restore").description("put a backup back: the database's data becomes the backup's (it restarts)").argument("<db>", "its name").argument("<id>", `the backup's id (kvbox ${spec.command} backup ls <db>)`).option("-y, --yes", "do not ask for confirmation").option("--json", "print the database as JSON").action(async (name, id, opts, cmd) => {
9167
+ import { Command as Command114 } from "commander";
9168
+ var restoreCommand4 = (spec) => new Command114("restore").description("put a backup back: the database's data becomes the backup's (it restarts)").argument("<db>", "its name").argument("<id>", `the backup's id (kvbox ${spec.command} backup ls <db>)`).option("-y, --yes", "do not ask for confirmation").option("--json", "print the database as JSON").action(async (name, id, opts, cmd) => {
8982
9169
  const client = await managedClient(cmd);
8983
9170
  try {
8984
9171
  const backup = await client.managedBackup(spec.kind, name, id);
@@ -9000,8 +9187,8 @@ var restoreCommand4 = (spec) => new Command112("restore").description("put a bac
9000
9187
  });
9001
9188
 
9002
9189
  // src/commands/managed/backup/rm.ts
9003
- import { Command as Command113 } from "commander";
9004
- var rmCommand16 = (spec) => new Command113("rm").alias("remove").description("remove a backup for good (a database's that is gone too)").argument("<db>", "its name").argument("<id>", `the backup's id (kvbox ${spec.command} backup ls <db>)`).option("-y, --yes", "do not ask for confirmation").action(async (name, id, opts, cmd) => {
9190
+ import { Command as Command115 } from "commander";
9191
+ var rmCommand16 = (spec) => new Command115("rm").alias("remove").description("remove a backup for good (a database's that is gone too)").argument("<db>", "its name").argument("<id>", `the backup's id (kvbox ${spec.command} backup ls <db>)`).option("-y, --yes", "do not ask for confirmation").action(async (name, id, opts, cmd) => {
9005
9192
  const client = await managedClient(cmd);
9006
9193
  try {
9007
9194
  await removeListed(client, await client.listManagedBackups(spec.kind), (b) => b.name, name, id, `database ${name}`, opts.yes ?? false);
@@ -9011,8 +9198,8 @@ var rmCommand16 = (spec) => new Command113("rm").alias("remove").description("re
9011
9198
  });
9012
9199
 
9013
9200
  // src/commands/managed/backup/schedule.ts
9014
- import { Command as Command114 } from "commander";
9015
- var scheduleCommand4 = (spec) => scheduleFlags(new Command114("schedule").description("show or change when a database is backed up on its own (daily, UTC)").argument("<db>", "its name")).action(
9201
+ import { Command as Command116 } from "commander";
9202
+ var scheduleCommand4 = (spec) => scheduleFlags(new Command116("schedule").description("show or change when a database is backed up on its own (daily, UTC)").argument("<db>", "its name")).action(
9016
9203
  async (name, flags, cmd) => {
9017
9204
  const change = changeOf(flags);
9018
9205
  const client = await managedClient(cmd);
@@ -9028,18 +9215,18 @@ var scheduleCommand4 = (spec) => scheduleFlags(new Command114("schedule").descri
9028
9215
 
9029
9216
  // src/commands/managed/backup/index.ts
9030
9217
  var backupCommand4 = (spec) => {
9031
- const command = new Command115("backup").description("back up a database to the kvbox cloud, list backups, restore or remove one, or change its nightly schedule");
9218
+ const command = new Command117("backup").description("back up a database to the kvbox cloud, list backups, restore or remove one, or change its nightly schedule");
9032
9219
  for (const make of [createCommand10, lsCommand17, restoreCommand4, rmCommand16, scheduleCommand4]) command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
9033
9220
  return command;
9034
9221
  };
9035
9222
 
9036
9223
  // src/commands/managed/create.ts
9037
- import { Command as Command116 } from "commander";
9224
+ import { Command as Command118 } from "commander";
9038
9225
  import { setTimeout as sleep5 } from "timers/promises";
9039
9226
  var READY_WAIT_MS = 9e4;
9040
9227
  var READY_STEP_MS = 2e3;
9041
9228
  var createCommand11 = (spec) => {
9042
- const command = new Command116("create").alias("new").description(`create a ${spec.title} database: a name is all it needs`).argument("<name>", "its name (1-12 chars, lowercase letters, digits and '-'); a linked box reaches it at <name>.<account>.kvbox");
9229
+ const command = new Command118("create").alias("new").description(`create a ${spec.title} database: a name is all it needs`).argument("<name>", "its name (1-12 chars, lowercase letters, digits and '-'); a linked box reaches it at <name>.<account>.kvbox");
9043
9230
  for (const o of spec.options) command.option(`--${o.name} <${o.arg}>`, o.help);
9044
9231
  return command.option("--password <password>", "its password (default: generated)").option("--storage <gb>", `storage for the data in GB (default: ${spec.storageGib}; it can grow later)`).option("--near <box>", "run it on the host of this box, so a link between them stays on that host").option("--from-backup <id>", `start it on this backup's data, a removed database's too (kvbox ${spec.command} backup ls)`).option("--json", "print it as JSON, password included").action(async (name, opts, cmd) => {
9045
9232
  const options = Object.fromEntries(spec.options.flatMap((o) => typeof opts[o.name] === "string" ? [[o.name, opts[o.name]]] : []));
@@ -9088,8 +9275,8 @@ var createCommand11 = (spec) => {
9088
9275
  };
9089
9276
 
9090
9277
  // src/commands/managed/grow.ts
9091
- import { Command as Command117 } from "commander";
9092
- var growCommand3 = (spec) => new Command117("grow").description("give a database more storage (it restarts once)").argument("<db>", "its name").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print as JSON").action(async (name, size, opts, cmd) => {
9278
+ import { Command as Command119 } from "commander";
9279
+ var growCommand3 = (spec) => new Command119("grow").description("give a database more storage (it restarts once)").argument("<db>", "its name").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print as JSON").action(async (name, size, opts, cmd) => {
9093
9280
  const storageGib = parseStorage(size, "size");
9094
9281
  const client = await managedClient(cmd);
9095
9282
  try {
@@ -9102,8 +9289,8 @@ var growCommand3 = (spec) => new Command117("grow").description("give a database
9102
9289
  });
9103
9290
 
9104
9291
  // src/commands/managed/info.ts
9105
- import { Command as Command118 } from "commander";
9106
- var infoCommand3 = (spec) => new Command118("info").alias("get").description("show one database: status, storage used, how to connect").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
9292
+ import { Command as Command120 } from "commander";
9293
+ var infoCommand3 = (spec) => new Command120("info").alias("get").description("show one database: status, storage used, how to connect").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
9107
9294
  const client = await managedClient(cmd);
9108
9295
  try {
9109
9296
  const m = await client.getManaged(spec.kind, name);
@@ -9115,8 +9302,8 @@ var infoCommand3 = (spec) => new Command118("info").alias("get").description("sh
9115
9302
  });
9116
9303
 
9117
9304
  // src/commands/managed/link.ts
9118
- import { Command as Command119 } from "commander";
9119
- var linkCommand2 = (spec) => new Command119("link").description("let a box reach a database privately").argument("<db>", "the database").argument("<box>", "the box that connects to it").option("--json", "print as JSON").action(async (name, box2, opts, cmd) => {
9305
+ import { Command as Command121 } from "commander";
9306
+ var linkCommand2 = (spec) => new Command121("link").description("let a box reach a database privately").argument("<db>", "the database").argument("<box>", "the box that connects to it").option("--json", "print as JSON").action(async (name, box2, opts, cmd) => {
9120
9307
  const client = await managedClient(cmd);
9121
9308
  try {
9122
9309
  const m = await spin(`linking ${box2} to ${name}\u2026`, client.linkManaged(spec.kind, name, box2));
@@ -9132,7 +9319,7 @@ var linkCommand2 = (spec) => new Command119("link").description("let a box reach
9132
9319
  });
9133
9320
 
9134
9321
  // src/commands/managed/ls.ts
9135
- import { Command as Command120 } from "commander";
9322
+ import { Command as Command122 } from "commander";
9136
9323
  function listRows(items, user, kindColumn) {
9137
9324
  return items.map((m) => ({
9138
9325
  owner: m.owner === user ? "private" : m.owner,
@@ -9146,7 +9333,7 @@ function listRows(items, user, kindColumn) {
9146
9333
  created: age(m.createdAt)
9147
9334
  }));
9148
9335
  }
9149
- var lsCommand18 = (spec) => new Command120("ls").alias("list").description(spec ? `list your ${spec.title} databases` : "list every managed database, whatever its kind").option("-a, --all", "every one on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
9336
+ var lsCommand18 = (spec) => new Command122("ls").alias("list").description(spec ? `list your ${spec.title} databases` : "list every managed database, whatever its kind").option("-a, --all", "every one on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
9150
9337
  const client = await managedClient(cmd);
9151
9338
  try {
9152
9339
  const items = await client.listManaged(spec?.kind, { all: opts.all });
@@ -9166,8 +9353,8 @@ var lsCommand18 = (spec) => new Command120("ls").alias("list").description(spec
9166
9353
  });
9167
9354
 
9168
9355
  // src/commands/managed/password.ts
9169
- import { Command as Command121 } from "commander";
9170
- var passwordCommand = (spec) => new Command121("password").description("show a database's password, or set a new one with --reset").argument("<db>", "its name").option("--reset", "make a new password; the old one stops working").option("--json", "print as JSON").action(async (name, opts, cmd) => {
9356
+ import { Command as Command123 } from "commander";
9357
+ var passwordCommand = (spec) => new Command123("password").description("show a database's password, or set a new one with --reset").argument("<db>", "its name").option("--reset", "make a new password; the old one stops working").option("--json", "print as JSON").action(async (name, opts, cmd) => {
9171
9358
  const client = await managedClient(cmd);
9172
9359
  try {
9173
9360
  const secret = opts.reset ? await spin(`setting a new password on ${name}\u2026`, client.resetManagedPassword(spec.kind, name)) : await client.managedPassword(spec.kind, name);
@@ -9183,8 +9370,8 @@ var passwordCommand = (spec) => new Command121("password").description("show a d
9183
9370
  });
9184
9371
 
9185
9372
  // src/commands/managed/public.ts
9186
- import { Command as Command122 } from "commander";
9187
- var publicCommand2 = (spec) => new Command122("public").description("open a database to the internet, or close it again").argument("<db>", "its name").argument("<state>", "on: reachable from anywhere with the password; off: only linked boxes").option("--json", "print as JSON").action(async (name, state, opts, cmd) => {
9373
+ import { Command as Command124 } from "commander";
9374
+ var publicCommand2 = (spec) => new Command124("public").description("open a database to the internet, or close it again").argument("<db>", "its name").argument("<state>", "on: reachable from anywhere with the password; off: only linked boxes").option("--json", "print as JSON").action(async (name, state, opts, cmd) => {
9188
9375
  if (state !== "on" && state !== "off") throw new KvboxError(`write on or off: kvbox ${spec.command} public ${name} on`);
9189
9376
  const client = await managedClient(cmd);
9190
9377
  try {
@@ -9205,8 +9392,8 @@ var publicCommand2 = (spec) => new Command122("public").description("open a data
9205
9392
  });
9206
9393
 
9207
9394
  // src/commands/managed/rm.ts
9208
- import { Command as Command123 } from "commander";
9209
- var rmCommand17 = (spec) => new Command123("rm").alias("remove").description("delete a database and all its data").argument("<db>", "its name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
9395
+ import { Command as Command125 } from "commander";
9396
+ var rmCommand17 = (spec) => new Command125("rm").alias("remove").description("delete a database and all its data").argument("<db>", "its name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
9210
9397
  const client = await managedClient(cmd);
9211
9398
  try {
9212
9399
  if (!await confirm(`Delete database ${name} and all its data? There is no backup.`, opts.yes ?? false)) {
@@ -9222,8 +9409,8 @@ var rmCommand17 = (spec) => new Command123("rm").alias("remove").description("de
9222
9409
  });
9223
9410
 
9224
9411
  // src/commands/managed/start.ts
9225
- import { Command as Command124 } from "commander";
9226
- var startCommand2 = (spec) => new Command124("start").description("run a stopped database again").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
9412
+ import { Command as Command126 } from "commander";
9413
+ var startCommand2 = (spec) => new Command126("start").description("run a stopped database again").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
9227
9414
  const client = await managedClient(cmd);
9228
9415
  try {
9229
9416
  const m = await spin(`starting ${name}\u2026`, client.startManaged(spec.kind, name));
@@ -9235,8 +9422,8 @@ var startCommand2 = (spec) => new Command124("start").description("run a stopped
9235
9422
  });
9236
9423
 
9237
9424
  // src/commands/managed/stop.ts
9238
- import { Command as Command125 } from "commander";
9239
- var stopCommand2 = (spec) => new Command125("stop").description("shut a database down, keeping its data (only its storage is charged)").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
9425
+ import { Command as Command127 } from "commander";
9426
+ var stopCommand2 = (spec) => new Command127("stop").description("shut a database down, keeping its data (only its storage is charged)").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
9240
9427
  const client = await managedClient(cmd);
9241
9428
  try {
9242
9429
  const m = await spin(`stopping ${name}\u2026`, client.stopManaged(spec.kind, name));
@@ -9248,8 +9435,8 @@ var stopCommand2 = (spec) => new Command125("stop").description("shut a database
9248
9435
  });
9249
9436
 
9250
9437
  // src/commands/managed/unlink.ts
9251
- import { Command as Command126 } from "commander";
9252
- var unlinkCommand2 = (spec) => new Command126("unlink").description("stop a box from reaching a database").argument("<db>", "the database").argument("<box>", "the box that was linked to it").option("--json", "print as JSON").action(async (name, box2, opts, cmd) => {
9438
+ import { Command as Command128 } from "commander";
9439
+ var unlinkCommand2 = (spec) => new Command128("unlink").description("stop a box from reaching a database").argument("<db>", "the database").argument("<box>", "the box that was linked to it").option("--json", "print as JSON").action(async (name, box2, opts, cmd) => {
9253
9440
  const client = await managedClient(cmd);
9254
9441
  try {
9255
9442
  const m = await spin(`unlinking ${box2} from ${name}\u2026`, client.unlinkManaged(spec.kind, name, box2));
@@ -9262,7 +9449,7 @@ var unlinkCommand2 = (spec) => new Command126("unlink").description("stop a box
9262
9449
 
9263
9450
  // src/commands/managed/kind.ts
9264
9451
  function kindCommand(spec, description) {
9265
- const command = new Command127(spec.command).aliases(spec.aliases).description(description);
9452
+ const command = new Command129(spec.command).aliases(spec.aliases).description(description);
9266
9453
  for (const make of [createCommand11, lsCommand18, infoCommand3, passwordCommand, publicCommand2, linkCommand2, unlinkCommand2, growCommand3, stopCommand2, startCommand2, rmCommand17]) {
9267
9454
  command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
9268
9455
  }
@@ -9277,14 +9464,14 @@ var pgCommand = kindCommand(POSTGRES2, "managed PostgreSQL: a database kvbox run
9277
9464
  var redisCommand = kindCommand(REDIS, "managed Redis (Valkey): a Redis kvbox runs for you, private until you link a box or make it public");
9278
9465
 
9279
9466
  // src/commands/managed/index.ts
9280
- import { Command as Command128 } from "commander";
9281
- var managedCommand = new Command128("managed").description(`databases kvbox runs for you, every kind together (${KINDS.map((k) => `${k.title}: kvbox ${k.command}`).join(", ")})`).addCommand(lsCommand18().option("--org <slug>", "act in this org (- for your personal databases)"));
9467
+ import { Command as Command130 } from "commander";
9468
+ var managedCommand = new Command130("managed").description(`databases kvbox runs for you, every kind together (${KINDS.map((k) => `${k.title}: kvbox ${k.command}`).join(", ")})`).addCommand(lsCommand18().option("--org <slug>", "act in this org (- for your personal databases)"));
9282
9469
 
9283
9470
  // src/commands/env/index.ts
9284
- import { Command as Command132 } from "commander";
9471
+ import { Command as Command134 } from "commander";
9285
9472
 
9286
9473
  // src/commands/env/ls.ts
9287
- import { Command as Command129 } from "commander";
9474
+ import { Command as Command131 } from "commander";
9288
9475
 
9289
9476
  // src/commands/env/shared.ts
9290
9477
  function requireCloud4(client) {
@@ -9311,7 +9498,7 @@ function firstBootHint(box2, name) {
9311
9498
  }
9312
9499
 
9313
9500
  // src/commands/env/ls.ts
9314
- var lsCommand19 = new Command129("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) => {
9501
+ var lsCommand19 = new Command131("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) => {
9315
9502
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
9316
9503
  try {
9317
9504
  if (opts.box !== void 0) {
@@ -9350,8 +9537,8 @@ var lsCommand19 = new Command129("ls").alias("list").description("list the varia
9350
9537
  });
9351
9538
 
9352
9539
  // src/commands/env/rm.ts
9353
- import { Command as Command130 } from "commander";
9354
- var rmCommand18 = new Command130("rm").alias("remove").description("remove variables; boxes lose them when they next start").argument("<names...>", "variable names").option("-y, --yes", "do not ask for confirmation").option("--box <box>", "remove this box's own variables (yours, or the org's, of the same name come back)").option("--json", "print as JSON").action(async (names2, opts, cmd) => {
9540
+ import { Command as Command132 } from "commander";
9541
+ var rmCommand18 = new Command132("rm").alias("remove").description("remove variables; boxes lose them when they next start").argument("<names...>", "variable names").option("-y, --yes", "do not ask for confirmation").option("--box <box>", "remove this box's own variables (yours, or the org's, of the same name come back)").option("--json", "print as JSON").action(async (names2, opts, cmd) => {
9355
9542
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
9356
9543
  try {
9357
9544
  const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
@@ -9388,8 +9575,8 @@ var rmCommand18 = new Command130("rm").alias("remove").description("remove varia
9388
9575
  });
9389
9576
 
9390
9577
  // src/commands/env/set.ts
9391
- import { Command as Command131 } from "commander";
9392
- var setCommand2 = new Command131("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) => {
9578
+ import { Command as Command133 } from "commander";
9579
+ var setCommand2 = new Command133("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) => {
9393
9580
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
9394
9581
  try {
9395
9582
  const owner = opts.box === void 0 ? requireCloud4(client) : void 0;
@@ -9426,14 +9613,14 @@ var setCommand2 = new Command131("set").description("add or change a variable; b
9426
9613
  });
9427
9614
 
9428
9615
  // src/commands/env/index.ts
9429
- var envCommand = new Command132("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand19, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand18);
9616
+ var envCommand = new Command134("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand19, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand18);
9430
9617
  for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
9431
9618
 
9432
9619
  // src/commands/domain/index.ts
9433
- import { Command as Command136 } from "commander";
9620
+ import { Command as Command138 } from "commander";
9434
9621
 
9435
9622
  // src/commands/domain/add.ts
9436
- import { Command as Command133 } from "commander";
9623
+ import { Command as Command135 } from "commander";
9437
9624
 
9438
9625
  // src/commands/domain/shared.ts
9439
9626
  function requireCloud5(client) {
@@ -9453,7 +9640,7 @@ function hostIn(name, zone) {
9453
9640
  }
9454
9641
 
9455
9642
  // src/commands/domain/add.ts
9456
- var addCommand4 = new Command133("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) => {
9643
+ var addCommand4 = new Command135("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) => {
9457
9644
  const domain = assertDomain(domainArg.trim().toLowerCase());
9458
9645
  const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
9459
9646
  const client = await clientFor(cmd.optsWithGlobals());
@@ -9489,8 +9676,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
9489
9676
  });
9490
9677
 
9491
9678
  // src/commands/domain/ls.ts
9492
- import { Command as Command134 } from "commander";
9493
- var lsCommand20 = new Command134("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
9679
+ import { Command as Command136 } from "commander";
9680
+ var lsCommand20 = new Command136("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
9494
9681
  const client = await clientFor(cmd.optsWithGlobals());
9495
9682
  try {
9496
9683
  requireCloud5(client);
@@ -9519,8 +9706,8 @@ var lsCommand20 = new Command134("ls").alias("list").description("list your cust
9519
9706
  });
9520
9707
 
9521
9708
  // src/commands/domain/rm.ts
9522
- import { Command as Command135 } from "commander";
9523
- var rmCommand19 = new Command135("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) => {
9709
+ import { Command as Command137 } from "commander";
9710
+ var rmCommand19 = new Command137("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) => {
9524
9711
  const domain = domainArg.trim().toLowerCase();
9525
9712
  const client = await clientFor(cmd.optsWithGlobals());
9526
9713
  try {
@@ -9541,7 +9728,7 @@ var rmCommand19 = new Command135("rm").alias("remove").description("stop serving
9541
9728
  });
9542
9729
 
9543
9730
  // src/commands/domain/index.ts
9544
- var domainCommand = new Command136("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand4).addCommand(lsCommand20).addCommand(rmCommand19);
9731
+ var domainCommand = new Command138("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand4).addCommand(lsCommand20).addCommand(rmCommand19);
9545
9732
  for (const cmd of domainCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
9546
9733
 
9547
9734
  // src/commands/update.ts
@@ -9549,7 +9736,7 @@ import { spawn as spawn8 } from "child_process";
9549
9736
  import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
9550
9737
  import { tmpdir } from "os";
9551
9738
  import { join as join9 } from "path";
9552
- import { Command as Command137 } from "commander";
9739
+ import { Command as Command139 } from "commander";
9553
9740
 
9554
9741
  // src/update.ts
9555
9742
  import { mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
@@ -9668,7 +9855,7 @@ function run2(cmd, args) {
9668
9855
  child.on("exit", (code, signal) => resolve4(code ?? (signal ? 1 : 0)));
9669
9856
  });
9670
9857
  }
9671
- var selfUpdateCommand = new Command137("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
9858
+ var selfUpdateCommand = new Command139("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
9672
9859
  suppressUpdateNotice();
9673
9860
  const inst = installerFor(process.platform, process.env["KVBOX_INSTALL_URL"] || INSTALL_BASE);
9674
9861
  let code;
@@ -9692,7 +9879,7 @@ var selfUpdateCommand = new Command137("update").description("update kvbox to th
9692
9879
  import { chmod as chmod2, mkdir as mkdir4, readFile as readFile9, writeFile as writeFile5 } from "fs/promises";
9693
9880
  import { homedir as homedir2 } from "os";
9694
9881
  import { dirname as dirname2, join as join11 } from "path";
9695
- import { Command as Command138 } from "commander";
9882
+ import { Command as Command140 } from "commander";
9696
9883
 
9697
9884
  // src/sshConfig.ts
9698
9885
  import { spawnSync as spawnSync4 } from "child_process";
@@ -9756,19 +9943,19 @@ async function windowsLauncher(kvbox, p) {
9756
9943
  const short = res.status === 0 ? res.stdout.trim() : "";
9757
9944
  return short !== "" && !/\s/.test(short) ? short : file;
9758
9945
  }
9759
- function spliceBlock(text2, block4) {
9946
+ function spliceBlock(text2, block5) {
9760
9947
  const eol = text2.includes("\r\n") ? "\r\n" : "\n";
9761
9948
  const lines = text2.split(/\r?\n/);
9762
9949
  const begin = lines.findIndex((l) => l.trim().startsWith("# BEGIN kvbox"));
9763
9950
  const end = begin === -1 ? -1 : lines.findIndex((l, i) => i > begin && l.trim() === END_MARK);
9764
- const add = block4 === void 0 ? [] : block4.split("\n");
9951
+ const add = block5 === void 0 ? [] : block5.split("\n");
9765
9952
  let out;
9766
9953
  if (begin !== -1 && end !== -1) {
9767
9954
  const after = lines.slice(end + 1);
9768
- if (block4 === void 0 && after[0] === "") after.shift();
9955
+ if (block5 === void 0 && after[0] === "") after.shift();
9769
9956
  out = [...lines.slice(0, begin), ...add, ...after];
9770
9957
  } else {
9771
- if (block4 === void 0) return text2;
9958
+ if (block5 === void 0) return text2;
9772
9959
  const rest = text2 === "" ? [] : ["", ...lines];
9773
9960
  out = [...add, ...rest];
9774
9961
  }
@@ -9776,6 +9963,18 @@ function spliceBlock(text2, block4) {
9776
9963
  if (joined !== "" && !joined.endsWith(eol)) joined += eol;
9777
9964
  return joined;
9778
9965
  }
9966
+ function listedHosts(text2) {
9967
+ const lines = text2.split(/\r?\n/);
9968
+ const begin = lines.findIndex((l) => l.trim().startsWith("# BEGIN kvbox"));
9969
+ if (begin === -1) return [];
9970
+ const hosts = [];
9971
+ for (const line of lines.slice(begin + 1)) {
9972
+ if (line.trim() === END_MARK) break;
9973
+ const m = /^Host\s+(\S+)\s*$/.exec(line.trim());
9974
+ if (m && m[1] !== "*") hosts.push(m[1]);
9975
+ }
9976
+ return hosts;
9977
+ }
9779
9978
  var idsFile = (p) => join10(p.ssh, "ssh-config.json");
9780
9979
  function namesHost(line, alias) {
9781
9980
  const field = line.trim().split(/\s+/)[0] ?? "";
@@ -9802,13 +10001,13 @@ async function forgetReplacedBox(alias, id, p) {
9802
10001
  }
9803
10002
 
9804
10003
  // src/commands/sshConfig.ts
9805
- var sshConfigCommand = new Command138("ssh-config").description("add your boxes to ~/.ssh/config, so ssh and VS Code Remote-SSH reach them as <box>.kvbox").option("--file <path>", "the ssh config file to write (default: ~/.ssh/config)").option("--remove", "take the kvbox block out of the file").option("--json", "print the result as JSON").action(async (opts, cmd) => {
10004
+ var sshConfigCommand = new Command140("ssh-config").description("add your boxes to ~/.ssh/config, so ssh and VS Code Remote-SSH reach them as <box>.kvbox").argument("[box...]", "only these boxes, added to the ones listed already (default: every box)").option("--remove", "take these boxes off the list; with no box, take the whole kvbox block out").option("--file <path>", "the ssh config file to write (default: ~/.ssh/config)").option("--json", "print the result as JSON").action(async (boxes, opts, cmd) => {
9806
10005
  const file = opts.file ?? join11(homedir2(), ".ssh", "config");
9807
10006
  const before = await readFile9(file, "utf8").catch((err) => {
9808
10007
  if (err.code === "ENOENT") return "";
9809
10008
  throw err;
9810
10009
  });
9811
- if (opts.remove) {
10010
+ if (opts.remove && boxes.length === 0) {
9812
10011
  const after = spliceBlock(before, void 0);
9813
10012
  const removed = after !== before;
9814
10013
  if (removed) await writeFile5(file, after);
@@ -9818,39 +10017,58 @@ var sshConfigCommand = new Command138("ssh-config").description("add your boxes
9818
10017
  }
9819
10018
  const globals = cmd.optsWithGlobals();
9820
10019
  const client = await clientFor(globals);
9821
- let hosts;
10020
+ let named;
10021
+ let all = [];
9822
10022
  try {
9823
10023
  await ensureCert(client);
9824
- const mine = me(client);
9825
- hosts = (await client.listMachines()).map((b) => ({ host: sshAlias(b, mine), box: b.name, owner: b.owner })).sort((a, b) => a.host.localeCompare(b.host));
10024
+ named = await aliasesOf(client, boxes, opts.remove === true);
10025
+ if (boxes.length === 0) all = named;
9826
10026
  } finally {
9827
10027
  await client.close();
9828
10028
  }
10029
+ const listed = listedHosts(before);
10030
+ const hosts = boxes.length === 0 ? all : opts.remove ? listed.filter((h) => !named.includes(h)) : [.../* @__PURE__ */ new Set([...listed, ...named])];
10031
+ hosts.sort((a, b) => a.localeCompare(b));
9829
10032
  const p = paths();
9830
10033
  const kvbox = launcher();
9831
10034
  const renewWith = process.platform === "win32" ? await windowsLauncher(kvbox, p) : void 0;
9832
- const block4 = renderBlock({ kvbox, renewWith, local: globals.local === true, hosts: hosts.map((h) => h.host), p });
10035
+ const block5 = renderBlock({ kvbox, renewWith, local: globals.local === true, hosts, p });
9833
10036
  await mkdir4(dirname2(file), { recursive: true, mode: 448 });
9834
10037
  const fresh = before === "";
9835
- await writeFile5(file, spliceBlock(before, block4));
10038
+ await writeFile5(file, spliceBlock(before, block5));
9836
10039
  if (fresh) await chmod2(file, 384).catch(() => void 0);
9837
10040
  if (opts.json) return json({ file, removed: false, hosts });
9838
10041
  if (client.target.kind === "cloud" && client.target.env === true) {
9839
10042
  warn("KVBOX_TOKEN is set in this shell only: ssh started elsewhere (VS Code) uses your kvbox login instead");
9840
10043
  }
9841
10044
  info(`wrote the kvbox block to ${file}`);
9842
- if (hosts.length === 0) info("you have no boxes yet; any <box>.kvbox works once you make one");
10045
+ if (opts.remove) info(`took ${named.join(", ")} off the list`);
10046
+ if (hosts.length === 0) info("VS Code lists no box; any <box>.kvbox still works with ssh");
9843
10047
  else {
9844
- info(`your boxes: ${hosts.map((h) => h.host).join(", ")}`);
9845
- info(`connect with ${color.bold(`ssh ${hosts[0].host}`)}, or in VS Code: Remote-SSH: Connect to Host\u2026 \u2192 ${hosts[0].host}`);
10048
+ info(`VS Code lists: ${hosts.join(", ")}`);
10049
+ info(`connect with ${color.bold(`ssh ${hosts[0]}`)}, or in VS Code: Remote-SSH: Connect to Host\u2026 \u2192 ${hosts[0]}`);
9846
10050
  }
9847
- info(color.dim("a box made later works as <box>.kvbox right away; run this again to have VS Code list it"));
10051
+ info(color.dim("any other box works as <box>.kvbox too; kvbox ssh-config <box> adds it to the list"));
9848
10052
  });
10053
+ async function aliasesOf(client, boxes, gone) {
10054
+ const mine = me(client);
10055
+ const list = await client.listMachines();
10056
+ if (boxes.length === 0) return list.map((b) => sshAlias(b, mine));
10057
+ return boxes.map((name) => {
10058
+ const box2 = pickRef(list, name, mine);
10059
+ if (!box2 && gone) {
10060
+ const [slug, bare] = name.includes("/") ? name.split("/", 2) : [mine ?? "", name];
10061
+ return sshAlias({ name: bare, owner: slug }, mine);
10062
+ }
10063
+ if (!box2) throw new KvboxError(`box ${name}: not found (kvbox ls)`);
10064
+ return sshAlias(box2, mine);
10065
+ });
10066
+ }
9849
10067
 
9850
10068
  // src/commands/sshProxy.ts
9851
10069
  import { connect } from "net";
9852
- import { Command as Command139 } from "commander";
9853
- var sshProxyCommand = new Command139("ssh-proxy").description("connect ssh to a box (used by kvbox ssh-config)").argument("<host>", "the ssh name: <box>.kvbox or <box>.<org>.kvbox").option("--renew", "only renew the SSH certificate if it is about to expire").action(async (host, opts, cmd) => {
10070
+ import { Command as Command141 } from "commander";
10071
+ var sshProxyCommand = new Command141("ssh-proxy").description("connect ssh to a box (used by kvbox ssh-config)").argument("<host>", "the ssh name: <box>.kvbox or <box>.<org>.kvbox").option("--renew", "only renew the SSH certificate if it is about to expire").action(async (host, opts, cmd) => {
9854
10072
  const ref = parseAlias(host);
9855
10073
  if (ref === void 0) throw new KvboxError(`${host}: not a kvbox name (<box>.kvbox or <box>.<org>.kvbox)`);
9856
10074
  const client = await clientFor(cmd.optsWithGlobals());
@@ -10012,7 +10230,7 @@ function installRootHelp(program) {
10012
10230
 
10013
10231
  // src/program.ts
10014
10232
  function buildProgram() {
10015
- const program = new Command140("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 and KVBOX_TOKEN").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();
10233
+ const program = new Command142("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 and KVBOX_TOKEN").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();
10016
10234
  program.addCommand(vmCommand);
10017
10235
  program.addCommand(snapshotsCommand);
10018
10236
  program.addCommand(volumeCommand);