@kvbox/cli 0.6.18 → 0.6.19

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 Command141 } 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.19" : void 0);
174
174
 
175
175
  // src/commands/vm/index.ts
176
- import { Command as Command42 } from "commander";
176
+ import { Command as Command43 } 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
@@ -1765,17 +1765,77 @@ import { setTimeout as sleep2 } from "timers/promises";
1765
1765
  import { Agent, request } from "undici";
1766
1766
 
1767
1767
  // ../sdk/src/machines.ts
1768
- import { z as z5 } from "zod";
1768
+ import { z as z6 } from "zod";
1769
1769
 
1770
- // ../shared/src/traffic.ts
1770
+ // ../shared/src/resources.ts
1771
1771
  import { z as z4 } from "zod";
1772
+ var RESOURCE_SLOT_MS = 5 * 6e4;
1773
+ var RESOURCE_KEEP_DAYS = 7;
1774
+ var RESOURCE_KEEP_MS = RESOURCE_KEEP_DAYS * 864e5;
1775
+ var whole = z4.number().int().nonnegative();
1776
+ var pct = z4.number().min(0).max(100);
1777
+ var small = whole.max(2 ** 31 - 1);
1778
+ var ResourceSlotRowSchema = z4.object({
1779
+ /** The host's box id. */
1780
+ boxId: z4.string(),
1781
+ owner: z4.string(),
1782
+ name: z4.string(),
1783
+ /** The slot's start, ms since the epoch. */
1784
+ slot: whole,
1785
+ vcpu: small,
1786
+ cpuMs: whole,
1787
+ wallMs: whole,
1788
+ cpuMaxPct: pct,
1789
+ memSamples: small,
1790
+ memSumMib: whole,
1791
+ memMaxMib: small,
1792
+ memTotalMib: small.nullable(),
1793
+ diskUsedBytes: whole.nullable(),
1794
+ diskTotalBytes: whole.nullable(),
1795
+ netInBytes: whole,
1796
+ netOutBytes: whole
1797
+ });
1798
+ var ResourceSlotsResponseSchema = z4.object({
1799
+ slots: z4.array(ResourceSlotRowSchema),
1800
+ next: whole
1801
+ });
1802
+ var ResourceSlotsPageSchema = z4.object({ slots: z4.array(z4.unknown()), next: whole });
1803
+ var figures = {
1804
+ /** Average and busiest minute, percent of the box's vCPUs; null when the CPU was not measured. */
1805
+ cpuPct: pct.nullable(),
1806
+ cpuMaxPct: pct.nullable(),
1807
+ /** 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). */
1808
+ memUsedMib: whole.nullable(),
1809
+ memMaxMib: whole.nullable(),
1810
+ memTotalMib: whole.nullable(),
1811
+ /** The box's own disk as the guest last said. */
1812
+ diskUsedBytes: whole.nullable(),
1813
+ diskTotalBytes: whole.nullable(),
1814
+ netInBytes: whole,
1815
+ netOutBytes: whole
1816
+ };
1817
+ var ResourcePointSchema = z4.object({ at: z4.string(), ...figures });
1818
+ var ResourceReportSchema = z4.object({
1819
+ box: z4.string(),
1820
+ owner: z4.string(),
1821
+ since: z4.string(),
1822
+ until: z4.string(),
1823
+ stepMin: z4.number().int().positive(),
1824
+ /** The box's vCPUs as last measured; null without a row. */
1825
+ vcpu: whole.nullable(),
1826
+ totals: z4.object(figures),
1827
+ points: z4.array(ResourcePointSchema)
1828
+ });
1829
+
1830
+ // ../shared/src/traffic.ts
1831
+ import { z as z5 } from "zod";
1772
1832
  var TRAFFIC_SLOT_MS = 5 * 6e4;
1773
1833
  var TRAFFIC_KEEP_DAYS = 7;
1774
1834
  var TRAFFIC_KEEP_MS = TRAFFIC_KEEP_DAYS * 864e5;
1775
1835
  var LATENCY_BUCKETS_MS = [5, 10, 25, 50, 100, 250, 500, 1e3, 2500, 5e3, 1e4, 3e4];
1776
1836
  var LATENCY_BUCKET_COUNT = LATENCY_BUCKETS_MS.length + 1;
1777
- var count = z4.number().int().nonnegative();
1778
- var figures = {
1837
+ var count = z5.number().int().nonnegative();
1838
+ var figures2 = {
1779
1839
  requests: count,
1780
1840
  s2xx: count,
1781
1841
  s3xx: count,
@@ -1790,28 +1850,28 @@ var figures = {
1790
1850
  p50Ms: count.nullable(),
1791
1851
  p95Ms: count.nullable()
1792
1852
  };
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(),
1853
+ var TrafficPointSchema = z5.object({ at: z5.string(), ...figures2 });
1854
+ var TrafficReportSchema = z5.object({
1855
+ box: z5.string(),
1856
+ owner: z5.string(),
1857
+ since: z5.string(),
1858
+ until: z5.string(),
1859
+ stepMin: z5.number().int().positive(),
1800
1860
  /** The one host name asked for; null for all of the box's. */
1801
- host: z4.string().nullable(),
1861
+ host: z5.string().nullable(),
1802
1862
  /** 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)
1863
+ hosts: z5.array(z5.string()),
1864
+ totals: z5.object(figures2),
1865
+ points: z5.array(TrafficPointSchema)
1806
1866
  });
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)
1867
+ var BoxTrafficSchema = z5.object({ box: z5.string(), owner: z5.string(), ...figures2 });
1868
+ var TrafficOverviewSchema = z5.object({
1869
+ since: z5.string(),
1870
+ until: z5.string(),
1871
+ stepMin: z5.number().int().positive(),
1872
+ totals: z5.object(figures2),
1873
+ points: z5.array(TrafficPointSchema),
1874
+ boxes: z5.array(BoxTrafficSchema)
1815
1875
  });
1816
1876
 
1817
1877
  // ../sdk/src/errors.ts
@@ -1924,7 +1984,7 @@ var Machines = class {
1924
1984
  ports;
1925
1985
  /** Every box the caller can read (their own and their orgs'), sorted by owner then name. */
1926
1986
  list(opts = {}) {
1927
- return this.transport.request("GET", `/machines${listQuery(opts)}`, z5.array(MachineSchema), { org: opts.org });
1987
+ return this.transport.request("GET", `/machines${listQuery(opts)}`, z6.array(MachineSchema), { org: opts.org });
1928
1988
  }
1929
1989
  /**
1930
1990
  * One box, found in the listing (the API has no route for a single box). `slug/name` looks in that
@@ -1938,7 +1998,7 @@ var Machines = class {
1938
1998
  async find(name, orgOpt, timeoutMs) {
1939
1999
  const slash = name.indexOf("/");
1940
2000
  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 });
2001
+ const listing = await this.transport.request("GET", "/machines", z6.array(MachineSchema), { org, timeoutMs });
1942
2002
  const named = listing.filter((m) => m.name === bare && (slash === -1 || slugOf2(m.owner) === org));
1943
2003
  if (named.length <= 1) {
1944
2004
  if (named[0] !== void 0) return named[0];
@@ -1972,7 +2032,7 @@ var Machines = class {
1972
2032
  }
1973
2033
  /** Remove the box and its disk. */
1974
2034
  async remove(name, opts = {}) {
1975
- await this.transport.request("DELETE", box(name), z5.undefined(), { org: opts.org });
2035
+ await this.transport.request("DELETE", box(name), z6.undefined(), { org: opts.org });
1976
2036
  }
1977
2037
  /** Boot a stopped box. */
1978
2038
  start(name, opts = {}) {
@@ -2115,6 +2175,15 @@ var Machines = class {
2115
2175
  traffic(name, opts = {}) {
2116
2176
  return this.transport.request("GET", box(name, `/traffic${trafficQuery(opts)}`), TrafficReportSchema, { org: opts.org });
2117
2177
  }
2178
+ /**
2179
+ * The box's CPU, memory, disk and network over time, measured by its host once a minute while it runs and
2180
+ * kept 7 days in five-minute slots: average and peak CPU as a percent of its vCPUs, average and peak memory,
2181
+ * disk as last seen, network bytes each way. The last 24 hours by default. Memory and disk are null when the
2182
+ * box itself gave no answer.
2183
+ */
2184
+ resources(name, opts = {}) {
2185
+ return this.transport.request("GET", box(name, `/resources${trafficQuery(opts)}`), ResourceReportSchema, { org: opts.org });
2186
+ }
2118
2187
  };
2119
2188
  var iso = (d) => typeof d === "string" ? d : d.toISOString();
2120
2189
  function trafficQuery(opts) {
@@ -2139,7 +2208,7 @@ var slugOf2 = (owner) => {
2139
2208
  };
2140
2209
 
2141
2210
  // ../sdk/src/snapshots.ts
2142
- import { z as z6 } from "zod";
2211
+ import { z as z7 } from "zod";
2143
2212
  var Snapshots = class {
2144
2213
  constructor(transport) {
2145
2214
  this.transport = transport;
@@ -2147,19 +2216,19 @@ var Snapshots = class {
2147
2216
  transport;
2148
2217
  /** Every snapshot the caller can read. */
2149
2218
  list(opts = {}) {
2150
- return this.transport.request("GET", `/snapshots${listQuery(opts)}`, z6.array(SnapshotSchema), { org: opts.org });
2219
+ return this.transport.request("GET", `/snapshots${listQuery(opts)}`, z7.array(SnapshotSchema), { org: opts.org });
2151
2220
  }
2152
2221
  /** Snapshot box `req.box` as `req.name` (`replace`: retake one that exists). The box is paused while it is taken. */
2153
2222
  create(req, opts = {}) {
2154
2223
  return this.transport.request("POST", "/snapshots", SnapshotSchema, { body: req, org: opts.org });
2155
2224
  }
2156
2225
  async remove(name, opts = {}) {
2157
- await this.transport.request("DELETE", `/snapshots/${encodeURIComponent(name)}`, z6.undefined(), { org: opts.org });
2226
+ await this.transport.request("DELETE", `/snapshots/${encodeURIComponent(name)}`, z7.undefined(), { org: opts.org });
2158
2227
  }
2159
2228
  };
2160
2229
 
2161
2230
  // ../sdk/src/transport.ts
2162
- import { z as z7 } from "zod";
2231
+ import { z as z8 } from "zod";
2163
2232
  var Transport = class {
2164
2233
  baseUrl;
2165
2234
  org;
@@ -2233,7 +2302,7 @@ var Transport = class {
2233
2302
  }
2234
2303
  }
2235
2304
  };
2236
- var LooseApiErrorSchema = z7.object({ error: z7.string(), code: z7.string().optional() });
2305
+ var LooseApiErrorSchema = z8.object({ error: z8.string(), code: z8.string().optional() });
2237
2306
  function safeJson(text2) {
2238
2307
  try {
2239
2308
  return JSON.parse(text2);
@@ -2251,7 +2320,7 @@ function errorCode(err) {
2251
2320
  }
2252
2321
 
2253
2322
  // ../sdk/src/integrations.ts
2254
- import { z as z8 } from "zod";
2323
+ import { z as z9 } from "zod";
2255
2324
  var Integrations = class {
2256
2325
  constructor(transport) {
2257
2326
  this.transport = transport;
@@ -2259,12 +2328,12 @@ var Integrations = class {
2259
2328
  transport;
2260
2329
  /** Each readable slug's state for each integration (`org`: one org's), connected or not; never a credential. */
2261
2330
  list(opts = {}) {
2262
- return this.transport.request("GET", "/integrations", z8.array(IntegrationSchema), { org: opts.org });
2331
+ return this.transport.request("GET", "/integrations", z9.array(IntegrationSchema), { org: opts.org });
2263
2332
  }
2264
2333
  };
2265
2334
 
2266
2335
  // ../sdk/src/volumes.ts
2267
- import { z as z9 } from "zod";
2336
+ import { z as z10 } from "zod";
2268
2337
  var volume = (name, rest = "") => `/volumes/${encodeURIComponent(name)}${rest}`;
2269
2338
  var Volumes = class {
2270
2339
  constructor(transport) {
@@ -2272,7 +2341,7 @@ var Volumes = class {
2272
2341
  }
2273
2342
  transport;
2274
2343
  list(opts = {}) {
2275
- return this.transport.request("GET", `/volumes${listQuery(opts)}`, z9.array(VolumeSchema), { org: opts.org });
2344
+ return this.transport.request("GET", `/volumes${listQuery(opts)}`, z10.array(VolumeSchema), { org: opts.org });
2276
2345
  }
2277
2346
  /**
2278
2347
  * Make a volume of `sizeGib` GiB. Through the cloud `box` is required: the volume is made on that
@@ -2295,7 +2364,7 @@ var Volumes = class {
2295
2364
  }
2296
2365
  /** Remove the volume and its data; it must be detached first. */
2297
2366
  async remove(name, opts = {}) {
2298
- await this.transport.request("DELETE", volume(name), z9.undefined(), { org: opts.org });
2367
+ await this.transport.request("DELETE", volume(name), z10.undefined(), { org: opts.org });
2299
2368
  }
2300
2369
  };
2301
2370
 
@@ -2345,41 +2414,41 @@ var Kvbox = class {
2345
2414
  };
2346
2415
 
2347
2416
  // src/client.ts
2348
- import { z as z14 } from "zod";
2417
+ import { z as z15 } from "zod";
2349
2418
 
2350
2419
  // ../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),
2420
+ import { z as z11 } from "zod";
2421
+ var PricingSchema = z11.object({
2422
+ currency: z11.string().min(1),
2423
+ vcpuHour: z11.number().nonnegative(),
2424
+ ramGibHour: z11.number().nonnegative(),
2425
+ diskGibHour: z11.number().nonnegative(),
2426
+ volumeHour: z11.number().nonnegative().default(0),
2427
+ volumeGibHour: z11.number().nonnegative().default(0),
2428
+ diskIncludedGib: z11.number().int().nonnegative().default(0),
2360
2429
  /**
2361
2430
  * Object storage (#182): an hour of a slug's storage existing, whatever it holds, which covers its
2362
2431
  * hidden box and the first `storageIncludedGib` of its size; each GiB above that is `storageGibHour`.
2363
2432
  * A price list from before object storage charges nothing for it.
2364
2433
  */
2365
- storageHour: z10.number().nonnegative().default(0),
2366
- storageGibHour: z10.number().nonnegative().default(0),
2367
- storageIncludedGib: z10.number().int().nonnegative().default(0),
2434
+ storageHour: z11.number().nonnegative().default(0),
2435
+ storageGibHour: z11.number().nonnegative().default(0),
2436
+ storageIncludedGib: z11.number().int().nonnegative().default(0),
2368
2437
  /** 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),
2438
+ cronHour: z11.number().nonnegative().default(0),
2370
2439
  /**
2371
2440
  * One backup a person starts, of anything, charged once it is ready (decision "A backup taken by hand
2372
2441
  * costs a flat price…"); a failed one costs nothing. A price list from before it charges nothing.
2373
2442
  */
2374
- backup: z10.number().nonnegative().default(0),
2443
+ backup: z11.number().nonnegative().default(0),
2375
2444
  /**
2376
2445
  * One nightly backup of a box, a volume or the object storage, charged once it is ready (decision "A nightly
2377
2446
  * backup you switch on is charged…"): their switch is off until someone turns it on. A managed database's
2378
2447
  * nightly backup, on from its creation, is included in its price. A price list from before it charges nothing.
2379
2448
  */
2380
- scheduledBackup: z10.number().nonnegative().default(0)
2449
+ scheduledBackup: z11.number().nonnegative().default(0)
2381
2450
  });
2382
- var PriceListSchema = PricingSchema.extend({ welcomeCredit: z10.number().nonnegative() });
2451
+ var PriceListSchema = PricingSchema.extend({ welcomeCredit: z11.number().nonnegative() });
2383
2452
  var HOUR_MS = 36e5;
2384
2453
  var round = (n2, places) => Math.round(n2 * 10 ** places) / 10 ** places;
2385
2454
  function costOf(t, pricing) {
@@ -2407,86 +2476,86 @@ function sumUsage(items, pricing) {
2407
2476
  var DAY_MS = 24 * HOUR_MS;
2408
2477
 
2409
2478
  // ../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({
2479
+ import { z as z12 } from "zod";
2480
+ var PriceSchema = z12.object({ perMonth: z12.number(), storagePerMonth: z12.number(), currency: z12.string() });
2481
+ var ManagedCatalogEntrySchema = z12.object({
2413
2482
  /** The kind, as in `/managed/<kind>`: `postgres`. */
2414
- kind: z11.string(),
2483
+ kind: z12.string(),
2415
2484
  /** The CLI command for it: `pg` (`kvbox pg create …`). */
2416
- command: z11.string(),
2417
- title: z11.string(),
2418
- description: z11.string(),
2485
+ command: z12.string(),
2486
+ title: z12.string(),
2487
+ description: z12.string(),
2419
2488
  /** The version a new one runs, as shown: `18`. */
2420
- version: z11.string(),
2489
+ version: z12.string(),
2421
2490
  /** The port a linked box reaches it on. */
2422
- port: z11.number().int(),
2491
+ port: z12.number().int(),
2423
2492
  /** The port `public on` opens behind a host port: `port` again unless the kind serves TLS on another. */
2424
- publicPort: z11.number().int(),
2493
+ publicPort: z12.number().int(),
2425
2494
  /** 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() }),
2495
+ docs: z12.string().optional(),
2496
+ storage: z12.object({ defaultGib: z12.number().int(), minGib: z12.number().int(), maxGib: z12.number().int() }),
2428
2497
  /**
2429
2498
  * What create takes of this kind alone, beside what every kind takes (name, password, storage, near): a
2430
2499
  * flag and a form field each, all optional, `default` in words.
2431
2500
  */
2432
- options: z11.array(z11.object({ name: z11.string(), title: z11.string(), description: z11.string(), default: z11.string() })),
2501
+ options: z12.array(z12.object({ name: z12.string(), title: z12.string(), description: z12.string(), default: z12.string() })),
2433
2502
  /** A month of it running with the default storage, and each further GB of storage. */
2434
- price: PriceSchema.extend({ storageGibPerMonth: z11.number() }),
2503
+ price: PriceSchema.extend({ storageGibPerMonth: z12.number() }),
2435
2504
  /** Whether a host answering now can run it. */
2436
- available: z11.boolean()
2505
+ available: z12.boolean()
2437
2506
  });
2438
- var CreateManagedRequest = z11.object({
2439
- name: z11.string(),
2507
+ var CreateManagedRequest = z12.object({
2508
+ name: z12.string(),
2440
2509
  /** 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(),
2510
+ options: z12.record(z12.string(), z12.string()).optional(),
2511
+ password: z12.string().optional(),
2512
+ storageGib: z12.number().int().optional(),
2444
2513
  /** Place it on the host of this box, so the box can be linked to it. */
2445
- near: z11.string().optional(),
2514
+ near: z12.string().optional(),
2446
2515
  /**
2447
2516
  * A backup of a database of the same kind and major version, of the same account (#186): the new
2448
2517
  * service starts on its data, a removed service's included. Its settings (Postgres: database, user)
2449
2518
  * are the backup's; the password is the new one.
2450
2519
  */
2451
- fromBackup: z11.string().optional()
2520
+ fromBackup: z12.string().optional()
2452
2521
  });
2453
- var ManagedHealthSchema = z11.object({
2522
+ var ManagedHealthSchema = z12.object({
2454
2523
  /** Its first start has finished: it has set itself up on its storage. */
2455
- ready: z11.boolean(),
2524
+ ready: z12.boolean(),
2456
2525
  /** It accepts connections. */
2457
- accepting: z11.boolean(),
2458
- version: z11.string(),
2526
+ accepting: z12.boolean(),
2527
+ version: z12.string(),
2459
2528
  /** The storage volume: what is used of it and its size. */
2460
- storageUsedBytes: z11.number().optional(),
2461
- storageTotalBytes: z11.number().optional(),
2529
+ storageUsedBytes: z12.number().optional(),
2530
+ storageTotalBytes: z12.number().optional(),
2462
2531
  /** What else the kind reports, ready to show: `{title: "Connections", value: "3"}`. */
2463
- facts: z11.array(z11.object({ title: z11.string(), value: z11.string() }))
2532
+ facts: z12.array(z12.object({ title: z12.string(), value: z12.string() }))
2464
2533
  });
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(),
2534
+ var UrlsSchema = z12.object({ private: z12.string(), public: z12.string().optional() });
2535
+ var ManagedSchema = z12.object({
2536
+ kind: z12.string(),
2537
+ name: z12.string(),
2469
2538
  /** The owning slug, bare. */
2470
- owner: z11.string(),
2471
- ownerKind: z11.enum(["user", "org"]),
2539
+ owner: z12.string(),
2540
+ ownerKind: z12.enum(["user", "org"]),
2472
2541
  /** `running`, `stopped` (storage only is charged), `hibernated` or `standby` (out of credit), `unknown` (its host does not answer). */
2473
2542
  status: BoxStatusSchema,
2474
2543
  /** The catalog version: `18`. */
2475
- version: z11.string(),
2544
+ version: z12.string(),
2476
2545
  /** 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(),
2546
+ settings: z12.record(z12.string(), z12.string()),
2547
+ storageGib: z12.number().int(),
2479
2548
  /** 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() }),
2549
+ private: z12.object({ host: z12.string(), port: z12.number().int() }),
2481
2550
  /** 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(),
2551
+ public: z12.object({ host: z12.string(), port: z12.number().int() }).nullable(),
2483
2552
  /** The boxes linked to it, as the caller would name them. */
2484
- links: z11.array(z11.string()),
2553
+ links: z12.array(z12.string()),
2485
2554
  /** 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(),
2555
+ host: z12.string(),
2556
+ country: z12.string().optional(),
2557
+ createdBy: z12.string().nullable(),
2558
+ createdAt: z12.string(),
2490
2559
  /** Connection strings with the password as `****`. */
2491
2560
  urls: UrlsSchema,
2492
2561
  price: PriceSchema,
@@ -2495,232 +2564,232 @@ var ManagedSchema = z11.object({
2495
2564
  /** Only in `GET /managed/<kind>/<name>` (asked live): null when it is not running or did not answer. */
2496
2565
  health: ManagedHealthSchema.nullable().optional()
2497
2566
  });
2498
- var ManagedSecretSchema = z11.object({ password: z11.string(), urls: UrlsSchema });
2567
+ var ManagedSecretSchema = z12.object({ password: z12.string(), urls: UrlsSchema });
2499
2568
  var CreatedManagedSchema = ManagedSchema.extend({
2500
2569
  secret: ManagedSecretSchema,
2501
2570
  /** 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),
2571
+ fromBackup: z12.string().optional()
2572
+ });
2573
+ var ResetPasswordRequest = z12.object({ password: z12.string().optional() });
2574
+ var SetPublicRequest = z12.object({ on: z12.boolean() });
2575
+ var ManagedLinkRequest = z12.object({ box: z12.string() });
2576
+ var GrowManagedRequest = z12.object({ storageGib: z12.number().int() });
2577
+ var ManagedBackupSchema = z12.object({
2578
+ id: z12.string(),
2579
+ owner: z12.string(),
2580
+ kind: z12.string(),
2581
+ name: z12.string(),
2582
+ version: z12.string(),
2583
+ status: z12.enum(BACKUP_STATUSES),
2515
2584
  /** Why it failed; null otherwise. */
2516
- error: z11.string().nullable(),
2585
+ error: z12.string().nullable(),
2517
2586
  /** The service's storage when taken. */
2518
- diskBytes: z11.number().int().nullable(),
2587
+ diskBytes: z12.number().int().nullable(),
2519
2588
  /** What it holds: the slots that are not all zeros. */
2520
- dataBytes: z11.number().int().nullable(),
2589
+ dataBytes: z12.number().int().nullable(),
2521
2590
  /** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
2522
- uploadedBytes: z11.number().int().nullable(),
2591
+ uploadedBytes: z12.number().int().nullable(),
2523
2592
  /** Who asked for it; for a scheduled one, the database's creator. */
2524
- createdBy: z11.string().nullable(),
2593
+ createdBy: z12.string().nullable(),
2525
2594
  /** 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()
2595
+ scheduled: z12.boolean().default(false),
2596
+ createdAt: z12.string(),
2597
+ finishedAt: z12.string().nullable()
2529
2598
  });
2530
2599
 
2531
2600
  // ../shared/src/cron.ts
2532
- import { z as z12 } from "zod";
2601
+ import { z as z13 } from "zod";
2533
2602
  var DEFAULT_CRON_COMMAND_TIMEOUT_SEC = 600;
2534
2603
  var MAX_CRON_COMMAND_TIMEOUT_SEC = 3600;
2535
2604
  var CRON_RUN_LOG_DIR = "/var/log/kvbox/runs";
2536
2605
  var CRON_METHODS = ["GET", "POST"];
2537
2606
  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(),
2607
+ var CronServiceSchema = z13.object({
2608
+ owner: z13.string(),
2609
+ ownerKind: z13.enum(["user", "org"]),
2610
+ name: z13.string(),
2542
2611
  /** Runs kept per trigger. */
2543
- keepRuns: z12.number().int(),
2544
- triggers: z12.number().int(),
2545
- createdBy: z12.string().nullable(),
2546
- createdAt: z12.string(),
2612
+ keepRuns: z13.number().int(),
2613
+ triggers: z13.number().int(),
2614
+ createdBy: z13.string().nullable(),
2615
+ createdAt: z13.string(),
2547
2616
  /** What it costs while it exists; on the answer to `POST /cron` only. */
2548
- price: z12.object({ perMonth: z12.number(), currency: z12.string() }).optional()
2617
+ price: z13.object({ perMonth: z13.number(), currency: z13.string() }).optional()
2549
2618
  });
2550
2619
  var triggerCommon = {
2551
- id: z12.string(),
2552
- service: z12.string(),
2553
- owner: z12.string(),
2620
+ id: z13.string(),
2621
+ service: z13.string(),
2622
+ owner: z13.string(),
2554
2623
  /** The box it acts on; a trigger is removed with its box. */
2555
- box: z12.string(),
2624
+ box: z13.string(),
2556
2625
  /** Five fields, `minute hour day-of-month month day-of-week`. */
2557
- expr: z12.string(),
2626
+ expr: z13.string(),
2558
2627
  /** An IANA zone (`Europe/Bucharest`) the expression is read in; `UTC` unless said. */
2559
- timezone: z12.string(),
2628
+ timezone: z13.string(),
2560
2629
  /** False: paused, it fires again when resumed. */
2561
- enabled: z12.boolean(),
2630
+ enabled: z13.boolean(),
2562
2631
  /** 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()
2632
+ nextRunAt: z13.string().nullable(),
2633
+ lastRunAt: z13.string().nullable(),
2634
+ lastOutcome: z13.enum(CRON_OUTCOMES).nullable(),
2635
+ createdBy: z13.string().nullable(),
2636
+ createdAt: z13.string()
2568
2637
  };
2569
- var CronHttpTriggerSchema = z12.object({
2638
+ var CronHttpTriggerSchema = z13.object({
2570
2639
  ...triggerCommon,
2571
- kind: z12.literal("http"),
2572
- method: z12.enum(CRON_METHODS),
2573
- port: z12.number().int(),
2640
+ kind: z13.literal("http"),
2641
+ method: z13.enum(CRON_METHODS),
2642
+ port: z13.number().int(),
2574
2643
  /** Path and query, starting with `/`. */
2575
- path: z12.string()
2644
+ path: z13.string()
2576
2645
  });
2577
- var CronCommandTriggerSchema = z12.object({
2646
+ var CronCommandTriggerSchema = z13.object({
2578
2647
  ...triggerCommon,
2579
- kind: z12.literal("command"),
2648
+ kind: z13.literal("command"),
2580
2649
  /** Run by a login shell as the box's user, in its home. */
2581
- command: z12.string(),
2650
+ command: z13.string(),
2582
2651
  /** The command is stopped after this long. */
2583
- timeoutSec: z12.number().int()
2652
+ timeoutSec: z13.number().int()
2584
2653
  });
2585
- var CronTriggerSchema = z12.discriminatedUnion("kind", [CronHttpTriggerSchema, CronCommandTriggerSchema]);
2586
- var CronRunSchema = z12.object({
2654
+ var CronTriggerSchema = z13.discriminatedUnion("kind", [CronHttpTriggerSchema, CronCommandTriggerSchema]);
2655
+ var CronRunSchema = z13.object({
2587
2656
  /** 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(),
2657
+ scheduledFor: z13.string(),
2658
+ startedAt: z13.string(),
2590
2659
  /** Null while `running`, and for a run that was never sent. */
2591
- durationMs: z12.number().int().nullable(),
2660
+ durationMs: z13.number().int().nullable(),
2592
2661
  /** The box's HTTP status; null when it never answered, and for a command. */
2593
- status: z12.number().int().nullable(),
2662
+ status: z13.number().int().nullable(),
2594
2663
  /** 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(),
2664
+ exitCode: z13.number().int().nullable(),
2596
2665
  /** 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),
2666
+ output: z13.string().nullable(),
2667
+ outcome: z13.enum(CRON_OUTCOMES),
2599
2668
  /** Why it did not end `ok`, in a line. */
2600
- error: z12.string().nullable(),
2669
+ error: z13.string().nullable(),
2601
2670
  /** The box was hibernated and this run woke it. */
2602
- woke: z12.boolean()
2671
+ woke: z13.boolean()
2603
2672
  });
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(),
2673
+ var CronCatalogSchema = z13.object({
2674
+ price: z13.object({ perMonth: z13.number(), currency: z13.string() }),
2675
+ maxServices: z13.number().int(),
2676
+ maxTriggers: z13.number().int(),
2677
+ keepRuns: z13.number().int(),
2609
2678
  /** The shortest time between two runs of one trigger, in seconds. */
2610
- minIntervalSeconds: z12.number().int(),
2679
+ minIntervalSeconds: z13.number().int(),
2611
2680
  /** How long a box has to answer, in seconds. */
2612
- timeoutSeconds: z12.number().int(),
2681
+ timeoutSeconds: z13.number().int(),
2613
2682
  /** 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(),
2683
+ commandTimeoutSeconds: z13.number().int(),
2684
+ maxCommandTimeoutSeconds: z13.number().int(),
2685
+ docs: z13.string().optional()
2686
+ });
2687
+ var CreateCronServiceRequest = z13.object({ name: z13.string() });
2688
+ var CreateCronTriggerRequest = z13.object({
2689
+ box: z13.string().min(1),
2690
+ expr: z13.string().min(1),
2691
+ timezone: z13.string().optional(),
2623
2692
  /** 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(),
2693
+ method: z13.enum(CRON_METHODS).optional(),
2694
+ port: z13.number().int().min(1).max(65535).optional(),
2695
+ path: z13.string().optional(),
2627
2696
  /** Or a command, with `timeoutSec`; exactly one of `port` and `command`. */
2628
- command: z12.string().optional(),
2629
- timeoutSec: z12.number().int().optional()
2697
+ command: z13.string().optional(),
2698
+ timeoutSec: z13.number().int().optional()
2630
2699
  });
2631
- var UpdateCronTriggerRequest = z12.object({ enabled: z12.boolean() });
2700
+ var UpdateCronTriggerRequest = z13.object({ enabled: z13.boolean() });
2632
2701
  var cronTarget = (t) => t.kind === "command" ? `${t.box}$ ${t.command}` : `${t.method} ${t.box}:${t.port}${t.path}`;
2633
2702
 
2634
2703
  // ../shared/src/storage.ts
2635
- import { z as z13 } from "zod";
2636
- var RegionSchema = z13.object({ name: z13.string(), country: z13.string().nullable() });
2704
+ import { z as z14 } from "zod";
2705
+ var RegionSchema = z14.object({ name: z14.string(), country: z14.string().nullable() });
2637
2706
  var MAX_PUBLIC_BUCKETS = 10;
2638
2707
  var STORAGE_BOX_SUBDOMAINS = MAX_PUBLIC_BUCKETS + 2;
2639
- var ObjectStorageSchema = z13.object({
2640
- owner: z13.string(),
2641
- ownerKind: z13.enum(["user", "org"]),
2708
+ var ObjectStorageSchema = z14.object({
2709
+ owner: z14.string(),
2710
+ ownerKind: z14.enum(["user", "org"]),
2642
2711
  /** `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(),
2712
+ endpoint: z14.string().nullable(),
2644
2713
  /** The S3 region every client of it signs with (`ro-west-1`): its host's when it was made. */
2645
- region: z13.string(),
2714
+ region: z14.string(),
2646
2715
  /** The most it may hold. */
2647
- sizeGib: z13.number().int(),
2716
+ sizeGib: z14.number().int(),
2648
2717
  /** `running` when it answers; `unknown` while its host is not heard from. */
2649
2718
  status: BoxStatusSchema,
2650
2719
  /** 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(),
2720
+ usedBytes: z14.number().optional(),
2721
+ totalBytes: z14.number().optional(),
2653
2722
  /** 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() });
2723
+ bucketUsage: z14.array(z14.object({ name: z14.string(), objects: z14.number(), bytes: z14.number() })).optional(),
2724
+ host: z14.string(),
2725
+ country: z14.string().optional(),
2726
+ buckets: z14.number().int(),
2727
+ price: z14.object({ perMonth: z14.number(), currency: z14.string() }),
2728
+ createdAt: z14.string()
2729
+ });
2730
+ var BucketSchema = z14.object({
2731
+ name: z14.string(),
2732
+ owner: z14.string(),
2733
+ ownerKind: z14.enum(["user", "org"]),
2734
+ endpoint: z14.string().nullable(),
2735
+ publicUrl: z14.string().optional(),
2736
+ region: z14.string(),
2737
+ keys: z14.number().int(),
2738
+ objects: z14.number().optional(),
2739
+ bytes: z14.number().optional(),
2740
+ createdBy: z14.string().nullable(),
2741
+ createdAt: z14.string()
2742
+ });
2743
+ var CreateBucketRequest = z14.object({
2744
+ name: z14.string(),
2745
+ sizeGib: z14.number().int().optional(),
2746
+ near: z14.string().optional(),
2747
+ region: z14.string().optional()
2748
+ });
2749
+ var CreatedBucketSchema = BucketSchema.extend({ storage: ObjectStorageSchema, storageCreated: z14.boolean() });
2681
2750
  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),
2751
+ var SetBucketPublicRequest = z14.object({ on: z14.boolean(), sub: z14.string().optional() });
2752
+ var BucketKeySchema = z14.object({
2753
+ id: z14.string(),
2754
+ name: z14.string(),
2755
+ bucket: z14.string(),
2756
+ owner: z14.string(),
2757
+ readOnly: z14.boolean(),
2758
+ createdBy: z14.string().nullable(),
2759
+ createdAt: z14.string()
2760
+ });
2761
+ var CreateBucketKeyRequest = z14.object({ name: z14.string().optional(), readOnly: z14.boolean().optional() });
2762
+ var CreatedBucketKeySchema = BucketKeySchema.extend({ secret: z14.string(), endpoint: z14.string().nullable(), region: z14.string() });
2763
+ var GrowStorageRequest = z14.object({ sizeGib: z14.number().int() });
2764
+ var StorageBackupSchema = z14.object({
2765
+ id: z14.string(),
2766
+ owner: z14.string(),
2767
+ status: z14.enum(BACKUP_STATUSES),
2699
2768
  /** Why it failed; null otherwise. */
2700
- error: z13.string().nullable(),
2769
+ error: z14.string().nullable(),
2701
2770
  /** The storage's volume when taken. */
2702
- diskBytes: z13.number().int().nullable(),
2771
+ diskBytes: z14.number().int().nullable(),
2703
2772
  /** What it holds: the slots that are not all zeros. */
2704
- dataBytes: z13.number().int().nullable(),
2773
+ dataBytes: z14.number().int().nullable(),
2705
2774
  /** What this backup added to the backup store (encrypted, compressed). */
2706
- uploadedBytes: z13.number().int().nullable(),
2775
+ uploadedBytes: z14.number().int().nullable(),
2707
2776
  /** 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(),
2777
+ buckets: z14.array(z14.string()),
2778
+ keys: z14.number().int(),
2779
+ createdBy: z14.string().nullable(),
2711
2780
  /** 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()
2781
+ scheduled: z14.boolean().default(false),
2782
+ createdAt: z14.string(),
2783
+ finishedAt: z14.string().nullable()
2715
2784
  });
2716
- var RestoredKeySchema = z13.object({ bucket: z13.string(), id: z13.string(), name: z13.string() });
2717
- var StorageRestoreSchema = z13.object({
2718
- backup: z13.string(),
2785
+ var RestoredKeySchema = z14.object({ bucket: z14.string(), id: z14.string(), name: z14.string() });
2786
+ var StorageRestoreSchema = z14.object({
2787
+ backup: z14.string(),
2719
2788
  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())
2789
+ buckets: z14.object({ kept: z14.array(z14.string()), returned: z14.array(z14.string()), removed: z14.array(z14.string()) }),
2790
+ keys: z14.object({ dropped: z14.array(RestoredKeySchema), revoked: z14.array(RestoredKeySchema) }),
2791
+ checked: z14.boolean(),
2792
+ warnings: z14.array(z14.string())
2724
2793
  });
2725
2794
  var OBJECT_LIST_MAX = 1e3;
2726
2795
  var SHARE_LINK_MAX_SEC = 7 * 24 * 3600;
@@ -2730,56 +2799,56 @@ var MULTIPART_PART_BYTES = 16 * 1024 * 1024;
2730
2799
  var UPLOAD_MAX_BYTES = 50 * 1024 * 1024 * 1024;
2731
2800
  var MOVE_MAX_BYTES = 5 * 1024 * 1024 * 1024;
2732
2801
  var DELETE_PREFIXES_MAX = 100;
2733
- var StoredObjectSchema = z13.object({
2734
- key: z13.string(),
2735
- size: z13.number(),
2736
- etag: z13.string(),
2802
+ var StoredObjectSchema = z14.object({
2803
+ key: z14.string(),
2804
+ size: z14.number(),
2805
+ etag: z14.string(),
2737
2806
  /** 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(),
2807
+ modified: z14.string()
2808
+ });
2809
+ var ObjectListingSchema = z14.object({
2810
+ prefix: z14.string(),
2811
+ folders: z14.array(z14.string()),
2812
+ objects: z14.array(StoredObjectSchema),
2813
+ next: z14.string().optional(),
2814
+ canWrite: z14.boolean()
2815
+ });
2816
+ var ObjectInfoSchema = StoredObjectSchema.extend({ contentType: z14.string() });
2817
+ var ObjectCountSchema = z14.object({ objects: z14.number(), bytes: z14.number(), more: z14.boolean() });
2818
+ var ObjectLinkRequest = z14.object({
2819
+ key: z14.string(),
2820
+ expiresSec: z14.number().int().positive(),
2752
2821
  /** Answer as a download (`Content-Disposition: attachment`) instead of showing it. */
2753
- download: z13.boolean().optional(),
2822
+ download: z14.boolean().optional(),
2754
2823
  /**
2755
2824
  * Let the browser keep what the link answers until the link expires (`Cache-Control: private`, `Expires`),
2756
2825
  * so the same link shown twice is fetched once. Asked again within the hour, for the same file as it
2757
2826
  * is, it is the same URL, and it lasts up to an hour longer than `expiresSec`. For the app's own previews.
2758
2827
  * Only a fetch of the whole file is kept so: the storage answers a part of one (`Range`) without the two headers.
2759
2828
  */
2760
- cached: z13.boolean().optional()
2829
+ cached: z14.boolean().optional()
2761
2830
  });
2762
- var ObjectLinkSchema = z13.object({ url: z13.string(), expiresAt: z13.string() });
2831
+ var ObjectLinkSchema = z14.object({ url: z14.string(), expiresAt: z14.string() });
2763
2832
  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()) })
2833
+ 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() });
2834
+ var UploadPlanSchema = z14.discriminatedUnion("kind", [
2835
+ z14.object({ kind: z14.literal("single"), url: z14.string() }),
2836
+ z14.object({ kind: z14.literal("multipart"), uploadId: z14.string(), partSize: z14.number(), urls: z14.array(z14.string()) })
2768
2837
  ]);
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)
2838
+ var CompleteUploadRequest = z14.object({
2839
+ key: z14.string(),
2840
+ uploadId: z14.string(),
2841
+ parts: z14.array(z14.object({ part: z14.number().int().positive(), etag: z14.string() })).min(1)
2773
2842
  });
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() }))
2843
+ var AbortUploadRequest = z14.object({ key: z14.string(), uploadId: z14.string() });
2844
+ var DeleteObjectsRequest = z14.object({ keys: z14.array(z14.string()).max(OBJECT_LIST_MAX).optional(), prefixes: z14.array(z14.string()).max(DELETE_PREFIXES_MAX).optional() });
2845
+ var DeletedObjectsSchema = z14.object({
2846
+ deleted: z14.number(),
2847
+ more: z14.boolean(),
2848
+ errors: z14.array(z14.object({ key: z14.string(), message: z14.string() }))
2780
2849
  });
2781
- var MoveObjectRequest = z13.object({ from: z13.string(), to: z13.string(), overwrite: z13.boolean().optional() });
2782
- var CreateFolderRequest = z13.object({ prefix: z13.string() });
2850
+ var MoveObjectRequest = z14.object({ from: z14.string(), to: z14.string(), overwrite: z14.boolean().optional() });
2851
+ var CreateFolderRequest = z14.object({ prefix: z14.string() });
2783
2852
 
2784
2853
  // src/kvm.ts
2785
2854
  import { accessSync, constants, readFileSync, statSync } from "fs";
@@ -2949,7 +3018,7 @@ var ServerClient = class {
2949
3018
  * `all`: every box on the platform (platform admins only, #78).
2950
3019
  */
2951
3020
  listMachines(opts = {}) {
2952
- return this.call("GET", `/machines${allQuery(opts)}`, z14.array(MachineSchema), void 0, opts.org);
3021
+ return this.call("GET", `/machines${allQuery(opts)}`, z15.array(MachineSchema), void 0, opts.org);
2953
3022
  }
2954
3023
  createMachine(req) {
2955
3024
  return this.call("POST", "/machines", MachineSchema, req, void 0, req.fromBackup !== void 0 ? 2 * 36e5 : void 0);
@@ -3003,10 +3072,10 @@ var ServerClient = class {
3003
3072
  }
3004
3073
  /** Backups, the control plane's only: a box's disk in object storage. Newest first. */
3005
3074
  listBackups() {
3006
- return this.call("GET", "/backups", z14.array(BackupSchema));
3075
+ return this.call("GET", "/backups", z15.array(BackupSchema));
3007
3076
  }
3008
3077
  boxBackups(name) {
3009
- return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z14.array(BackupSchema));
3078
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z15.array(BackupSchema));
3010
3079
  }
3011
3080
  boxBackup(name, id) {
3012
3081
  return this.call("GET", `/machines/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, BackupSchema);
@@ -3028,14 +3097,14 @@ var ServerClient = class {
3028
3097
  * later. Works for a backup whose box, volume or database is gone too.
3029
3098
  */
3030
3099
  removeBackup(id) {
3031
- return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z14.undefined());
3100
+ return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z15.undefined());
3032
3101
  }
3033
3102
  /** A volume's backups (#168): the same as a box's, of the volume's disk. Newest first. */
3034
3103
  listVolumeBackups() {
3035
- return this.call("GET", "/backups?kind=volume", z14.array(VolumeBackupSchema));
3104
+ return this.call("GET", "/backups?kind=volume", z15.array(VolumeBackupSchema));
3036
3105
  }
3037
3106
  volumeBackups(name) {
3038
- return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z14.array(VolumeBackupSchema));
3107
+ return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z15.array(VolumeBackupSchema));
3039
3108
  }
3040
3109
  volumeBackup(name, id) {
3041
3110
  return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, VolumeBackupSchema);
@@ -3061,7 +3130,7 @@ var ServerClient = class {
3061
3130
  }
3062
3131
  /** Wake hooks (#101), the control plane's only: a URL and a secret that wake the box. */
3063
3132
  boxHooks(name) {
3064
- return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z14.array(WakeHookSchema));
3133
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z15.array(WakeHookSchema));
3065
3134
  }
3066
3135
  createBoxHook(name) {
3067
3136
  return this.call("POST", `/machines/${encodeURIComponent(name)}/hooks`, CreatedWakeHookSchema);
@@ -3089,7 +3158,7 @@ var ServerClient = class {
3089
3158
  }
3090
3159
  /** Every readable box's subdomains, one entry each. */
3091
3160
  listSubdomains() {
3092
- return this.call("GET", "/subdomains", z14.array(SubdomainSchema));
3161
+ return this.call("GET", "/subdomains", z15.array(SubdomainSchema));
3093
3162
  }
3094
3163
  /** Custom domains (#89), the control plane's only: serve the box at the user's own name. */
3095
3164
  addDomain(name, req) {
@@ -3100,7 +3169,7 @@ var ServerClient = class {
3100
3169
  }
3101
3170
  /** Every readable box's custom domains. */
3102
3171
  listDomains() {
3103
- return this.call("GET", "/domains", z14.array(DomainSchema));
3172
+ return this.call("GET", "/domains", z15.array(DomainSchema));
3104
3173
  }
3105
3174
  /** A running box's own load, memory and disk, asked of its guest (#67). */
3106
3175
  machineStats(name) {
@@ -3115,6 +3184,10 @@ var ServerClient = class {
3115
3184
  machineTraffic(name, query) {
3116
3185
  return this.call("GET", `/machines/${encodeURIComponent(name)}/traffic${query}`, TrafficReportSchema);
3117
3186
  }
3187
+ /** A box's CPU, memory, disk and network over time (observability layer 2); a control plane only. `query`: "" or "?since=…". */
3188
+ machineResources(name, query) {
3189
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/resources${query}`, ResourceReportSchema);
3190
+ }
3118
3191
  /** Every box of the caller over the window (#41 on a host, #42 through a control plane); dates as the user wrote them. */
3119
3192
  usageReport(since, until2, all = false) {
3120
3193
  const q = new URLSearchParams();
@@ -3137,22 +3210,22 @@ var ServerClient = class {
3137
3210
  return this.call("POST", "/billing/redeem", RedeemResponseSchema, { code });
3138
3211
  }
3139
3212
  deleteMachine(name) {
3140
- return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z14.undefined());
3213
+ return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z15.undefined());
3141
3214
  }
3142
3215
  /** Like `listMachines`, for snapshots. */
3143
3216
  listSnapshots(opts = {}) {
3144
- return this.call("GET", `/snapshots${allQuery(opts)}`, z14.array(SnapshotSchema), void 0, opts.org);
3217
+ return this.call("GET", `/snapshots${allQuery(opts)}`, z15.array(SnapshotSchema), void 0, opts.org);
3145
3218
  }
3146
3219
  createSnapshot(req) {
3147
3220
  return this.call("POST", "/snapshots", SnapshotSchema, req);
3148
3221
  }
3149
3222
  deleteSnapshot(name) {
3150
- return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z14.undefined());
3223
+ return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z15.undefined());
3151
3224
  }
3152
3225
  // ---- environment variables (#88), a control plane only: the caller's slug, or `--org`'s ----
3153
3226
  /** `org`: that org's list instead of `--org`'s (or the caller's own). */
3154
3227
  listEnv(org) {
3155
- return this.call("GET", "/vars", z14.array(EnvVarSchema), void 0, org);
3228
+ return this.call("GET", "/vars", z15.array(EnvVarSchema), void 0, org);
3156
3229
  }
3157
3230
  setEnv(name, req) {
3158
3231
  return this.call("PUT", `/vars/${encodeURIComponent(name)}`, EnvChangeSchema, req);
@@ -3172,13 +3245,13 @@ var ServerClient = class {
3172
3245
  }
3173
3246
  // ---- volumes (#52) ----
3174
3247
  listVolumes(opts = {}) {
3175
- return this.call("GET", `/volumes${allQuery(opts)}`, z14.array(VolumeSchema), void 0, opts.org);
3248
+ return this.call("GET", `/volumes${allQuery(opts)}`, z15.array(VolumeSchema), void 0, opts.org);
3176
3249
  }
3177
3250
  createVolume(req) {
3178
3251
  return this.call("POST", "/volumes", VolumeSchema, req);
3179
3252
  }
3180
3253
  deleteVolume(name) {
3181
- return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z14.undefined());
3254
+ return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z15.undefined());
3182
3255
  }
3183
3256
  /** Both answer with the box as it is afterwards (restarted when it was running). */
3184
3257
  attachVolume(name, req) {
@@ -3193,7 +3266,7 @@ var ServerClient = class {
3193
3266
  }
3194
3267
  // ---- cron service (#190): the control plane's alone ----
3195
3268
  listCronServices(opts = {}) {
3196
- return this.call("GET", `/cron${allQuery(opts)}`, z14.array(CronServiceSchema), void 0, opts.org);
3269
+ return this.call("GET", `/cron${allQuery(opts)}`, z15.array(CronServiceSchema), void 0, opts.org);
3197
3270
  }
3198
3271
  createCronService(name) {
3199
3272
  return this.call("POST", "/cron", CronServiceSchema, { name });
@@ -3202,10 +3275,10 @@ var ServerClient = class {
3202
3275
  return this.call("GET", `/cron/${encodeURIComponent(name)}`, CronServiceSchema);
3203
3276
  }
3204
3277
  deleteCronService(name) {
3205
- return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z14.undefined());
3278
+ return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z15.undefined());
3206
3279
  }
3207
3280
  listCronTriggers(service) {
3208
- return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z14.array(CronTriggerSchema));
3281
+ return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z15.array(CronTriggerSchema));
3209
3282
  }
3210
3283
  addCronTrigger(service, req) {
3211
3284
  return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers`, CronTriggerSchema, req);
@@ -3215,18 +3288,18 @@ var ServerClient = class {
3215
3288
  return this.call("PATCH", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, CronTriggerSchema, { enabled: enabled2 });
3216
3289
  }
3217
3290
  deleteCronTrigger(service, id) {
3218
- return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, z14.undefined());
3291
+ return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, z15.undefined());
3219
3292
  }
3220
3293
  /** Marks it due: kvbox-cron fires it within a few seconds. */
3221
3294
  runCronTrigger(service, id) {
3222
3295
  return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/run`, CronTriggerSchema);
3223
3296
  }
3224
3297
  listCronRuns(service, id, limit) {
3225
- return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`, z14.array(CronRunSchema));
3298
+ return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`, z15.array(CronRunSchema));
3226
3299
  }
3227
3300
  // ---- object storage (#182): the control plane's alone ----
3228
3301
  listBuckets(opts = {}) {
3229
- return this.call("GET", `/buckets${allQuery(opts)}`, z14.array(BucketSchema), void 0, opts.org);
3302
+ return this.call("GET", `/buckets${allQuery(opts)}`, z15.array(BucketSchema), void 0, opts.org);
3230
3303
  }
3231
3304
  /** The first bucket of a slug also makes its storage: a box boots twice, so this may take a couple of minutes. */
3232
3305
  createBucket(req) {
@@ -3240,26 +3313,26 @@ var ServerClient = class {
3240
3313
  return this.call("PUT", `/buckets/${encodeURIComponent(name)}/public`, BucketSchema, req);
3241
3314
  }
3242
3315
  deleteBucket(name, force = false) {
3243
- return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`, z14.undefined());
3316
+ return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`, z15.undefined());
3244
3317
  }
3245
3318
  listBucketKeys(name) {
3246
- return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z14.array(BucketKeySchema));
3319
+ return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z15.array(BucketKeySchema));
3247
3320
  }
3248
3321
  createBucketKey(name, req) {
3249
3322
  return this.call("POST", `/buckets/${encodeURIComponent(name)}/keys`, CreatedBucketKeySchema, req);
3250
3323
  }
3251
3324
  deleteBucketKey(name, id) {
3252
- return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`, z14.undefined());
3325
+ return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`, z15.undefined());
3253
3326
  }
3254
3327
  listStorage(opts = {}) {
3255
- return this.call("GET", `/storage${allQuery(opts)}`, z14.array(ObjectStorageSchema), void 0, opts.org);
3328
+ return this.call("GET", `/storage${allQuery(opts)}`, z15.array(ObjectStorageSchema), void 0, opts.org);
3256
3329
  }
3257
3330
  growStorage(sizeGib) {
3258
3331
  return this.call("POST", "/storage/grow", ObjectStorageSchema, { sizeGib });
3259
3332
  }
3260
3333
  /** Backups of the slug's whole object storage (#186 slice 3), newest first. */
3261
3334
  storageBackups() {
3262
- return this.call("GET", "/storage/backups", z14.array(StorageBackupSchema));
3335
+ return this.call("GET", "/storage/backups", z15.array(StorageBackupSchema));
3263
3336
  }
3264
3337
  storageBackup(id) {
3265
3338
  return this.call("GET", `/storage/backups/${encodeURIComponent(id)}`, StorageBackupSchema);
@@ -3287,11 +3360,11 @@ var ServerClient = class {
3287
3360
  return `/managed/${encodeURIComponent(kind)}${name === void 0 ? "" : `/${encodeURIComponent(name)}`}${rest}`;
3288
3361
  }
3289
3362
  managedCatalog() {
3290
- return this.call("GET", "/managed/catalog", z14.array(ManagedCatalogEntrySchema));
3363
+ return this.call("GET", "/managed/catalog", z15.array(ManagedCatalogEntrySchema));
3291
3364
  }
3292
3365
  /** One kind's services, or every kind's when `kind` is left out. */
3293
3366
  listManaged(kind, opts = {}) {
3294
- return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`, z14.array(ManagedSchema), void 0, opts.org);
3367
+ return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`, z15.array(ManagedSchema), void 0, opts.org);
3295
3368
  }
3296
3369
  /** From a backup (`fromBackup`) it waits for the restore too: the control plane gives its host 2 h for the download. */
3297
3370
  createManaged(kind, req) {
@@ -3302,7 +3375,7 @@ var ServerClient = class {
3302
3375
  return this.call("GET", this.managedPath(kind, name), ManagedSchema);
3303
3376
  }
3304
3377
  deleteManaged(kind, name) {
3305
- return this.call("DELETE", this.managedPath(kind, name), z14.undefined());
3378
+ return this.call("DELETE", this.managedPath(kind, name), z15.undefined());
3306
3379
  }
3307
3380
  managedPassword(kind, name) {
3308
3381
  return this.call("GET", this.managedPath(kind, name, "/password"), ManagedSecretSchema);
@@ -3324,10 +3397,10 @@ var ServerClient = class {
3324
3397
  }
3325
3398
  /** 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
3399
  listManagedBackups(kind) {
3327
- return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z14.array(ManagedBackupSchema));
3400
+ return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z15.array(ManagedBackupSchema));
3328
3401
  }
3329
3402
  managedBackups(kind, name) {
3330
- return this.call("GET", this.managedPath(kind, name, "/backups"), z14.array(ManagedBackupSchema));
3403
+ return this.call("GET", this.managedPath(kind, name, "/backups"), z15.array(ManagedBackupSchema));
3331
3404
  }
3332
3405
  managedBackup(kind, name, id) {
3333
3406
  return this.call("GET", this.managedPath(kind, name, `/backups/${encodeURIComponent(id)}`), ManagedBackupSchema);
@@ -3369,7 +3442,7 @@ var ServerClient = class {
3369
3442
  return this.call("POST", "/login/device/token", DeviceLoginPollSchema, { deviceCode });
3370
3443
  }
3371
3444
  logout() {
3372
- return this.call("POST", "/logout", z14.unknown()).then(() => void 0);
3445
+ return this.call("POST", "/logout", z15.unknown()).then(() => void 0);
3373
3446
  }
3374
3447
  me() {
3375
3448
  return this.call("GET", "/me", MeResponseSchema);
@@ -3380,25 +3453,25 @@ var ServerClient = class {
3380
3453
  * credential. Null: each readable slug whatever `--org` says, which is how the caller's own slug is read.
3381
3454
  */
3382
3455
  listIntegrations(org) {
3383
- return this.call("GET", "/integrations", z14.array(IntegrationSchema), void 0, org);
3456
+ return this.call("GET", "/integrations", z15.array(IntegrationSchema), void 0, org);
3384
3457
  }
3385
3458
  /** What can be connected on this control plane, and by which kind of slug. */
3386
3459
  integrationCatalog() {
3387
- return this.call("GET", "/integrations/catalog", z14.array(IntegrationCatalogEntrySchema), void 0, null);
3460
+ return this.call("GET", "/integrations/catalog", z15.array(IntegrationCatalogEntrySchema), void 0, null);
3388
3461
  }
3389
3462
  // ---- API keys (`kvbox key …`, #189) ----
3390
3463
  listApiKeys() {
3391
- return this.call("GET", "/keys", z14.array(ApiKeySchema));
3464
+ return this.call("GET", "/keys", z15.array(ApiKeySchema));
3392
3465
  }
3393
3466
  createApiKey(req) {
3394
3467
  return this.call("POST", "/keys", CreatedApiKeySchema, req);
3395
3468
  }
3396
3469
  deleteApiKey(name) {
3397
- return this.call("DELETE", `/keys/${encodeURIComponent(name)}`, z14.unknown()).then(() => void 0);
3470
+ return this.call("DELETE", `/keys/${encodeURIComponent(name)}`, z15.unknown()).then(() => void 0);
3398
3471
  }
3399
3472
  // ---- orgs (`kvbox org …`) ----
3400
3473
  listOrgs() {
3401
- return this.call("GET", "/orgs", z14.array(OrgMembershipSchema));
3474
+ return this.call("GET", "/orgs", z15.array(OrgMembershipSchema));
3402
3475
  }
3403
3476
  createOrg(req) {
3404
3477
  return this.call("POST", "/orgs", CloudOrgSchema, req);
@@ -3407,16 +3480,16 @@ var ServerClient = class {
3407
3480
  return this.call("GET", `/orgs/${encodeURIComponent(slug)}`, OrgDetailSchema);
3408
3481
  }
3409
3482
  deleteOrg(slug) {
3410
- return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z14.undefined());
3483
+ return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z15.undefined());
3411
3484
  }
3412
3485
  addMember(slug, req) {
3413
- return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z14.undefined(), req);
3486
+ return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z15.undefined(), req);
3414
3487
  }
3415
3488
  setRole(slug, username, role) {
3416
- return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z14.unknown(), { role }).then(() => void 0);
3489
+ return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z15.unknown(), { role }).then(() => void 0);
3417
3490
  }
3418
3491
  removeMember(slug, username) {
3419
- return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z14.undefined());
3492
+ return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z15.undefined());
3420
3493
  }
3421
3494
  /** Sign this machine's key again (#51); the key must be one the user logged in with. */
3422
3495
  sshCert(req) {
@@ -5160,19 +5233,123 @@ function parseCount(text2) {
5160
5233
  return n2;
5161
5234
  }
5162
5235
  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;
5236
+ const mib2 = parseMib(text2);
5237
+ if (mib2 === void 0) throw new KvboxError(`${flag} ${text2}: give a size like 16GB or 4096MB`);
5238
+ return mib2;
5166
5239
  }
5167
5240
  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;
5241
+ const mib2 = parseSize(flag, text2);
5242
+ if (mib2 % 1024 !== 0) throw new KvboxError(`${flag} ${text2}: disk sizes are whole GB`);
5243
+ return mib2 / 1024;
5171
5244
  }
5172
5245
 
5173
- // src/commands/vm/resume.ts
5246
+ // src/commands/vm/resources.ts
5247
+ import { Command as Command33 } from "commander";
5248
+
5249
+ // src/commands/vm/traffic.ts
5174
5250
  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) => {
5251
+ 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) => {
5252
+ const q = new URLSearchParams();
5253
+ if (opts.since !== void 0) q.set("since", sinceOf(opts.since));
5254
+ if (opts.host !== void 0) q.set("host", opts.host);
5255
+ const client = await clientFor(cmd.optsWithGlobals());
5256
+ try {
5257
+ if (client.target.kind !== "cloud") throw new KvboxError("traffic is counted by the kvbox cloud's edge: kvbox login first");
5258
+ const report = await client.machineTraffic(name, q.size === 0 ? "" : `?${q.toString()}`);
5259
+ if (opts.json) json(report);
5260
+ else if (report.totals.requests === 0) info(`no requests reached ${name} through its HTTPS names since ${when(report.since)}`);
5261
+ else process.stdout.write(block2(report));
5262
+ } finally {
5263
+ await client.close();
5264
+ }
5265
+ });
5266
+ var UNITS = { m: 6e4, h: 36e5, d: 864e5 };
5267
+ function sinceOf(text2, now = Date.now()) {
5268
+ const span = /^(\d+)([mhd])$/.exec(text2.trim());
5269
+ if (span) return new Date(now - Number(span[1]) * UNITS[span[2]]).toISOString();
5270
+ const t = Date.parse(text2);
5271
+ if (Number.isNaN(t)) throw new KvboxError(`--since ${text2}: write a span like 1h, 24h or 7d, or a date like 2026-11-19`);
5272
+ return new Date(t).toISOString();
5273
+ }
5274
+ var when = (iso2) => `${iso2.slice(0, 16).replace("T", " ")} UTC`;
5275
+ var n = (v) => v.toLocaleString("en-US");
5276
+ function bytes(v) {
5277
+ if (v < 1e3) return `${v} B`;
5278
+ const units = ["kB", "MB", "GB", "TB"];
5279
+ let x = v;
5280
+ let u = -1;
5281
+ while (x >= 1e3 && u < units.length - 1) {
5282
+ x /= 1e3;
5283
+ u++;
5284
+ }
5285
+ return `${x < 10 ? x.toFixed(1) : Math.round(x)} ${units[u]}`;
5286
+ }
5287
+ var ms = (v) => v === null ? "-" : v >= 1e3 ? `${v / 1e3} s` : `${v} ms`;
5288
+ var share = (part, whole2) => whole2 === 0 || part === 0 ? "" : color.dim(` (${(part / whole2 * 100).toFixed(part === whole2 ? 0 : 1)}%)`);
5289
+ function block2(r) {
5290
+ const t = r.totals;
5291
+ const rows2 = [
5292
+ ["name", boxName(r.box)],
5293
+ ["window", `${when(r.since)} to ${when(r.until)}`],
5294
+ ["hosts", r.host ?? (r.hosts.join(", ") || "-")],
5295
+ ["requests", n(t.requests)],
5296
+ ["2xx", n(t.s2xx) + share(t.s2xx, t.requests)],
5297
+ ["3xx", n(t.s3xx) + share(t.s3xx, t.requests)],
5298
+ ["4xx", n(t.s4xx) + share(t.s4xx, t.requests)],
5299
+ ["5xx", (t.s5xx > 0 ? color.red(n(t.s5xx)) : "0") + share(t.s5xx, t.requests)],
5300
+ ["latency", `p50 \u2264 ${ms(t.p50Ms)}, p95 \u2264 ${ms(t.p95Ms)}`],
5301
+ ["bytes in", bytes(t.bytesIn)],
5302
+ ["bytes out", bytes(t.bytesOut)],
5303
+ ["wakes", t.wakes === 0 ? "0" : `${n(t.wakes)}, waited ${ms(t.wakeWaitMs)} on average`]
5304
+ ];
5305
+ const width2 = Math.max(...rows2.map(([k]) => k.length));
5306
+ const lines = rows2.map(([k, v]) => `${color.dim(k.padStart(width2))} ${v}`);
5307
+ lines.push(color.dim("published ports and SSH do not pass the edge and are not counted"));
5308
+ return `${lines.join("\n")}
5309
+ `;
5310
+ }
5311
+
5312
+ // src/commands/vm/resources.ts
5313
+ 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) => {
5314
+ const query = opts.since === void 0 ? "" : `?since=${encodeURIComponent(sinceOf(opts.since))}`;
5315
+ const client = await clientFor(cmd.optsWithGlobals());
5316
+ try {
5317
+ 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)");
5318
+ const report = await client.machineResources(name, query);
5319
+ if (opts.json) json(report);
5320
+ 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`);
5321
+ else process.stdout.write(block3(report));
5322
+ } finally {
5323
+ await client.close();
5324
+ }
5325
+ });
5326
+ var when2 = (iso2) => `${iso2.slice(0, 16).replace("T", " ")} UTC`;
5327
+ var pct2 = (v) => v === null ? "-" : `${v}%`;
5328
+ var mib = (v) => gb(v * 1024 ** 2);
5329
+ function block3(r) {
5330
+ const t = r.totals;
5331
+ const of = (total) => total === null ? "" : color.dim(` of ${total}`);
5332
+ const rows2 = [
5333
+ ["name", boxName(r.box)],
5334
+ ["window", `${when2(r.since)} to ${when2(r.until)}`],
5335
+ ["cpu", `${pct2(t.cpuPct)} average, ${pct2(t.cpuMaxPct)} busiest minute${r.vcpu === null ? "" : color.dim(` of ${r.vcpu} vCPU`)}`],
5336
+ ["memory", t.memUsedMib === null ? "-" : `${mib(t.memUsedMib)} average, ${mib(t.memMaxMib ?? t.memUsedMib)} highest${of(t.memTotalMib === null ? null : mib(t.memTotalMib))}`],
5337
+ // A disk in the units its size was asked in (`--disk 8GB`); the network rows are transfer, in decimal units like traffic.
5338
+ ["disk", t.diskUsedBytes === null ? "-" : `${gb(t.diskUsedBytes)}${of(t.diskTotalBytes === null ? null : gb(t.diskTotalBytes))}`],
5339
+ ["network in", bytes(t.netInBytes)],
5340
+ ["network out", bytes(t.netOutBytes)]
5341
+ ];
5342
+ const width2 = Math.max(...rows2.map(([k]) => k.length));
5343
+ const lines = rows2.map(([k, v]) => `${color.dim(k.padStart(width2))} ${v}`);
5344
+ 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)"));
5345
+ lines.push(color.dim("measured only while the box runs; network is everything on the box's interface, SSH and published ports included"));
5346
+ return `${lines.join("\n")}
5347
+ `;
5348
+ }
5349
+
5350
+ // src/commands/vm/resume.ts
5351
+ import { Command as Command34 } from "commander";
5352
+ var resumeCommand = new Command34("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
5353
  const client = await clientFor(cmd.optsWithGlobals());
5177
5354
  try {
5178
5355
  const box2 = await spin(`resuming ${name}\u2026`, client.resumeMachine(name));
@@ -5184,8 +5361,8 @@ var resumeCommand = new Command32("resume").description("continue a box that is
5184
5361
  });
5185
5362
 
5186
5363
  // 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) => {
5364
+ import { Command as Command35 } from "commander";
5365
+ var rmCommand4 = new Command35("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
5366
  const client = await clientFor(cmd.optsWithGlobals());
5190
5367
  try {
5191
5368
  const box2 = pickRef(await boxesFor(client, name), name, me(client));
@@ -5205,7 +5382,7 @@ var rmCommand4 = new Command33("rm").description("destroy a box (its disk is del
5205
5382
  });
5206
5383
 
5207
5384
  // src/commands/vm/set.ts
5208
- import { Command as Command34 } from "commander";
5385
+ import { Command as Command36 } from "commander";
5209
5386
 
5210
5387
  // src/swap.ts
5211
5388
  import { spawn as spawn4 } from "child_process";
@@ -5215,9 +5392,9 @@ var SWAP_MIN_MIB = 256;
5215
5392
  function parseSwap(text2) {
5216
5393
  const t = text2.trim().toLowerCase();
5217
5394
  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;
5395
+ const mib2 = parseMib(t);
5396
+ 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`);
5397
+ return mib2;
5221
5398
  }
5222
5399
  function swapScript() {
5223
5400
  return [
@@ -5261,16 +5438,16 @@ function swapScript() {
5261
5438
  'echo "kvbox-swap ${3:-0} ${4:-0} $(cat "$zs" 2>/dev/null || echo N)"'
5262
5439
  ].join("\n");
5263
5440
  }
5264
- function swapCommand(mib) {
5265
- return `sudo -n sh -c ${shellQuote(swapScript())} kvbox-swap ${mib}`;
5441
+ function swapCommand(mib2) {
5442
+ return `sudo -n sh -c ${shellQuote(swapScript())} kvbox-swap ${mib2}`;
5266
5443
  }
5267
5444
  function parseSwapReport(output) {
5268
5445
  const m = /^kvbox-swap (\d+) (\d+) (\S+)\s*$/m.exec(output);
5269
5446
  if (!m) return void 0;
5270
5447
  return { sizeMib: Math.round(Number(m[1]) / 1024), usedMib: Math.round(Number(m[2]) / 1024), zswap: m[3] === "Y" || m[3] === "1" };
5271
5448
  }
5272
- function runSwap(ep, mib) {
5273
- const child = spawn4("ssh", ["-n", ...sshArgs(ep), swapCommand(mib)], { stdio: ["ignore", "pipe", "pipe"] });
5449
+ function runSwap(ep, mib2) {
5450
+ const child = spawn4("ssh", ["-n", ...sshArgs(ep), swapCommand(mib2)], { stdio: ["ignore", "pipe", "pipe"] });
5274
5451
  const chunks = [];
5275
5452
  child.stdout.on("data", (c2) => chunks.push(c2));
5276
5453
  child.stderr.on("data", (c2) => chunks.push(c2));
@@ -5281,7 +5458,7 @@ function runSwap(ep, mib) {
5281
5458
  }
5282
5459
 
5283
5460
  // 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) => {
5461
+ var setCommand = new Command36("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
5462
  if (opts.autoHibernate === void 0 && opts.idleCheck === void 0 && opts.integration === void 0 && opts.swap === void 0) {
5286
5463
  throw new KvboxError("nothing to change: give --auto-hibernate, --idle-check, --integration or --swap");
5287
5464
  }
@@ -5322,17 +5499,17 @@ var setCommand = new Command34("set").description("change a box's settings, e.g.
5322
5499
  await client.close();
5323
5500
  }
5324
5501
  });
5325
- async function setSwap(client, found, name, mib, cmd) {
5502
+ async function setSwap(client, found, name, mib2, cmd) {
5326
5503
  const cert = await ensureCert(client, void 0, void 0, { owner: found.owner });
5327
5504
  const wasRunning = found.status === "running";
5328
5505
  const box2 = wasRunning ? found : await wakeUp(client, found, displayName(found, me(client)));
5329
5506
  const ep = sshEndpoint(box2, client.target);
5330
5507
  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));
5508
+ const what = mib2 === 0 ? `removing ${name}'s swap\u2026` : `setting up ${mib2 >= 1024 ? `${mib2 / 1024}G` : `${mib2}M`} of swap in ${name}\u2026`;
5509
+ let result = await spin(what, runSwap(ep, mib2));
5333
5510
  if (result.status === 255) {
5334
5511
  const again = await clientFor(cmd.optsWithGlobals());
5335
- if (await renewAfterRefusal(again, cert, found.owner).finally(() => again.close())) result = await spin(what, runSwap(ep, mib));
5512
+ if (await renewAfterRefusal(again, cert, found.owner).finally(() => again.close())) result = await spin(what, runSwap(ep, mib2));
5336
5513
  }
5337
5514
  const report = parseSwapReport(result.output);
5338
5515
  if (result.status !== 0 || !report) {
@@ -5359,8 +5536,8 @@ function parseIdleCheck(text2) {
5359
5536
  }
5360
5537
 
5361
5538
  // 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) => {
5539
+ import { Command as Command37 } from "commander";
5540
+ var startCommand = new Command37("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
5541
  const client = await clientFor(cmd.optsWithGlobals());
5365
5542
  try {
5366
5543
  const box2 = await spin(`booting ${name}\u2026`, client.startMachine(name, opts.force ?? false));
@@ -5372,8 +5549,8 @@ var startCommand = new Command35("start").description("boot a stopped box again
5372
5549
  });
5373
5550
 
5374
5551
  // 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) => {
5552
+ import { Command as Command38 } from "commander";
5553
+ var stopCommand = new Command38("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
5554
  const client = await clientFor(cmd.optsWithGlobals());
5378
5555
  try {
5379
5556
  const box2 = await spin(`shutting ${name} down\u2026`, client.stopMachine(name));
@@ -5385,8 +5562,8 @@ var stopCommand = new Command36("stop").description("shut a box down (its disk i
5385
5562
  });
5386
5563
 
5387
5564
  // 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) => {
5565
+ import { Command as Command39 } from "commander";
5566
+ var topCommand = new Command39("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
5567
  const client = await clientFor(cmd.optsWithGlobals());
5391
5568
  try {
5392
5569
  const running = (await client.listMachines({ all: opts.all })).filter((b) => b.status === "running");
@@ -5429,7 +5606,7 @@ async function mapLimit(items, limit, fn) {
5429
5606
  await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
5430
5607
  return out;
5431
5608
  }
5432
- var pct = (used, total) => total > 0 ? color.dim(` ${Math.round(used / total * 100)}%`) : "";
5609
+ var pct3 = (used, total) => total > 0 ? color.dim(` ${Math.round(used / total * 100)}%`) : "";
5433
5610
  function topRows(entries, cloud) {
5434
5611
  return entries.map((e) => {
5435
5612
  const s = e.stats;
@@ -5437,80 +5614,17 @@ function topRows(entries, cloud) {
5437
5614
  ...cloud ? { owner: ownerCell(e, cloud.me) } : {},
5438
5615
  name: boxName(e.name),
5439
5616
  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)}` : "-",
5617
+ mem: s ? `${gbShort(s.memUsedMib * 1024 ** 2)}/${gbShort(s.memTotalMib * 1024 ** 2)}${pct3(s.memUsedMib, s.memTotalMib)}` : "-",
5618
+ disk: s ? `${gbShort(s.diskUsedBytes)}/${gbShort(s.diskTotalBytes)}${pct3(s.diskUsedBytes, s.diskTotalBytes)}` : "-",
5442
5619
  // duration() writes "-" for 0, which here would read as "no numbers".
5443
5620
  uptime: s ? s.uptimeSec >= 1 ? duration(s.uptimeSec) : "0s" : "-"
5444
5621
  };
5445
5622
  });
5446
5623
  }
5447
5624
 
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
5625
  // 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) => {
5626
+ import { Command as Command40 } from "commander";
5627
+ var unlinkCommand = new Command40("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
5628
  const port = parseLinkPort(opts.port);
5515
5629
  if (!await confirm(`Cut box ${from} off from box ${name} port ${port}? Its open connections close too.`, opts.yes ?? false)) {
5516
5630
  info("cancelled");
@@ -5531,8 +5645,8 @@ var unlinkCommand = new Command39("unlink").description("take a link away (kvbox
5531
5645
  });
5532
5646
 
5533
5647
  // 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) => {
5648
+ import { Command as Command41 } from "commander";
5649
+ var updateCommand = new Command41("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
5650
  const client = await clientFor(cmd.optsWithGlobals());
5537
5651
  try {
5538
5652
  const before = pickRef(await boxesFor(client, name), name, me(client));
@@ -5554,8 +5668,8 @@ var updateCommand = new Command40("update").description("move a box onto the cur
5554
5668
  });
5555
5669
 
5556
5670
  // 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) => {
5671
+ import { Command as Command42 } from "commander";
5672
+ var wakeCommand = new Command42("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
5673
  const client = await clientFor(cmd.optsWithGlobals());
5560
5674
  try {
5561
5675
  const box2 = await spin(`waking ${name} (loading its memory from disk)\u2026`, client.wakeMachine(name, opts.force ?? false));
@@ -5567,7 +5681,7 @@ var wakeCommand = new Command41("wake").description("continue a hibernated box w
5567
5681
  });
5568
5682
 
5569
5683
  // 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);
5684
+ var vmCommand = new Command43("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(resourcesCommand).addCommand(topCommand).addCommand(proxyCommand).addCommand(hookCommand).addCommand(backupCommand).addCommand(linkCommand).addCommand(unlinkCommand).addCommand(linksCommand).addCommand(rmCommand4);
5571
5685
  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
5686
  var vmAliases = [newCommand, lsCommand, getCommand, connectCommand, execCommand, cpCommand, stopCommand, startCommand, pauseCommand, resumeCommand, hibernateCommand, wakeCommand, rmCommand4, claimCommand];
5573
5687
 
@@ -5576,7 +5690,7 @@ import { hostname as osHostname2 } from "os";
5576
5690
  import { createInterface as createInterface2 } from "readline/promises";
5577
5691
  import { setTimeout as sleep4 } from "timers/promises";
5578
5692
  import { Writable } from "stream";
5579
- import { Command as Command43 } from "commander";
5693
+ import { Command as Command44 } from "commander";
5580
5694
 
5581
5695
  // src/browser.ts
5582
5696
  import { spawn as spawn5 } from "child_process";
@@ -5613,7 +5727,7 @@ function openBrowser(url) {
5613
5727
  }
5614
5728
 
5615
5729
  // 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) => {
5730
+ var loginCommand = new Command44("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
5731
  const url = normalizeUrl(urlArg ?? DEFAULT_CLOUD_URL);
5618
5732
  const byPassword = opts.password === true || opts.passwordStdin === true || opts.email !== void 0;
5619
5733
  const session = byPassword ? await runLogin(url, await readCredentials(opts), paths()) : await runDeviceLogin(url, paths());
@@ -5723,8 +5837,8 @@ async function firstLine(stream) {
5723
5837
  }
5724
5838
 
5725
5839
  // 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 () => {
5840
+ import { Command as Command45 } from "commander";
5841
+ var logoutCommand = new Command45("logout").description("log out of the control plane; commands target this machine's kvbox-server again").action(async () => {
5728
5842
  const p = paths();
5729
5843
  const session = await readSession(p).catch(() => null);
5730
5844
  switch (await runLogout(p)) {
@@ -5762,8 +5876,8 @@ async function runLogout(p = paths()) {
5762
5876
  }
5763
5877
 
5764
5878
  // 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) => {
5879
+ import { Command as Command46 } from "commander";
5880
+ var whoamiCommand = new Command46("whoami").description("show which account and control plane commands target (or local mode)").option("--json", "print as JSON").action(async (opts, cmd) => {
5767
5881
  if (!cmd.optsWithGlobals().local && envLogin()) {
5768
5882
  const target = await resolveTarget({});
5769
5883
  if (target.kind !== "cloud") return;
@@ -5788,10 +5902,10 @@ function describeSession(session) {
5788
5902
  }
5789
5903
 
5790
5904
  // src/commands/key/index.ts
5791
- import { Command as Command49 } from "commander";
5905
+ import { Command as Command50 } from "commander";
5792
5906
 
5793
5907
  // src/commands/key/create.ts
5794
- import { Command as Command46 } from "commander";
5908
+ import { Command as Command47 } from "commander";
5795
5909
 
5796
5910
  // src/commands/key/shared.ts
5797
5911
  async function keyClient(cmd) {
@@ -5828,7 +5942,7 @@ function expiryText(expiresAt, now = Date.now()) {
5828
5942
  }
5829
5943
 
5830
5944
  // 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) => {
5945
+ var createCommand3 = new Command47("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
5946
  const expiresAt = opts.expires === void 0 ? void 0 : parseExpires(opts.expires);
5833
5947
  const client = await keyClient(cmd);
5834
5948
  try {
@@ -5846,8 +5960,8 @@ var createCommand3 = new Command46("create").description("make an API key for a
5846
5960
  });
5847
5961
 
5848
5962
  // 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) => {
5963
+ import { Command as Command48 } from "commander";
5964
+ var lsCommand5 = new Command48("ls").alias("list").description("list your API keys (never the keys themselves)").option("--json", "print as JSON").action(async (opts, cmd) => {
5851
5965
  const client = await keyClient(cmd);
5852
5966
  try {
5853
5967
  const keys = await client.listApiKeys();
@@ -5866,8 +5980,8 @@ var lsCommand5 = new Command47("ls").alias("list").description("list your API ke
5866
5980
  });
5867
5981
 
5868
5982
  // 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) => {
5983
+ import { Command as Command49 } from "commander";
5984
+ var rmCommand5 = new Command49("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
5985
  const client = await keyClient(cmd);
5872
5986
  try {
5873
5987
  if (!await confirm(`Remove API key ${name}? Whatever uses it stops working.`, opts.yes ?? false)) {
@@ -5883,14 +5997,14 @@ var rmCommand5 = new Command48("rm").alias("remove").description("remove an API
5883
5997
  });
5884
5998
 
5885
5999
  // 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);
6000
+ var keyCommand = new Command50("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
6001
 
5888
6002
  // src/commands/integration/index.ts
5889
- import { Command as Command51 } from "commander";
6003
+ import { Command as Command52 } from "commander";
5890
6004
 
5891
6005
  // 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) => {
6006
+ import { Command as Command51 } from "commander";
6007
+ var lsCommand6 = new Command51("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
6008
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
5895
6009
  try {
5896
6010
  if (client.target.kind !== "cloud") throw new KvboxError("integrations belong to an account on the kvbox cloud: kvbox login first");
@@ -5919,14 +6033,14 @@ var lsCommand6 = new Command50("ls").alias("list").description("list the account
5919
6033
  });
5920
6034
 
5921
6035
  // 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);
6036
+ var integrationCommand = new Command52("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
6037
 
5924
6038
  // src/commands/snapshots/index.ts
5925
- import { Command as Command55 } from "commander";
6039
+ import { Command as Command56 } from "commander";
5926
6040
 
5927
6041
  // 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) => {
6042
+ import { Command as Command53 } from "commander";
6043
+ var lsCommand7 = new Command53("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
6044
  const client = await clientFor(cmd.optsWithGlobals());
5931
6045
  try {
5932
6046
  const cloud = client.target.kind === "cloud";
@@ -5957,8 +6071,8 @@ var lsCommand7 = new Command52("ls").description("list snapshots (yours and your
5957
6071
  });
5958
6072
 
5959
6073
  // 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) => {
6074
+ import { Command as Command54 } from "commander";
6075
+ var newCommand2 = new Command54("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
6076
  const client = await clientFor(cmd.optsWithGlobals());
5963
6077
  try {
5964
6078
  const req = { box: box2, name, ...opts.replace ? { replace: true } : {} };
@@ -5971,8 +6085,8 @@ var newCommand2 = new Command53("new").description("freeze a running box (memory
5971
6085
  });
5972
6086
 
5973
6087
  // 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) => {
6088
+ import { Command as Command55 } from "commander";
6089
+ var rmCommand6 = new Command55("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
6090
  if (!await confirm(`Delete snapshot ${name}?`, opts.yes ?? false)) {
5977
6091
  info("cancelled");
5978
6092
  process.exitCode = 1;
@@ -5988,14 +6102,14 @@ var rmCommand6 = new Command54("rm").description("delete a snapshot (boxes made
5988
6102
  });
5989
6103
 
5990
6104
  // 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);
6105
+ var snapshotsCommand = new Command56("snapshots").aliases(["snapshot", "snap"]).description("freeze running boxes into snapshots and manage them").addCommand(newCommand2).addCommand(lsCommand7).addCommand(rmCommand6);
5992
6106
  for (const cmd of snapshotsCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
5993
6107
 
5994
6108
  // src/commands/org/index.ts
5995
- import { Command as Command61 } from "commander";
6109
+ import { Command as Command62 } from "commander";
5996
6110
 
5997
6111
  // src/commands/org/ls.ts
5998
- import { Command as Command56 } from "commander";
6112
+ import { Command as Command57 } from "commander";
5999
6113
 
6000
6114
  // src/commands/org/context.ts
6001
6115
  var NOT_LOGGED_IN2 = "orgs live on the control plane: kvbox login first";
@@ -6015,7 +6129,7 @@ function orgFor(opts, target) {
6015
6129
  }
6016
6130
 
6017
6131
  // 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) => {
6132
+ var lsCommand8 = new Command57("ls").description("list the orgs you belong to and your role in each").option("--json", "print as JSON").action(async (opts, cmd) => {
6019
6133
  const client = await cloudClientFor(cmd.optsWithGlobals());
6020
6134
  try {
6021
6135
  const orgs = await client.listOrgs();
@@ -6037,8 +6151,8 @@ function orgRows(orgs) {
6037
6151
  }
6038
6152
 
6039
6153
  // 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) => {
6154
+ import { Command as Command58, Option as Option4 } from "commander";
6155
+ var lsCommand9 = new Command58("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
6156
  const client = await cloudClientFor(cmd.optsWithGlobals());
6043
6157
  try {
6044
6158
  const org = await client.getOrg(orgFor(opts, client.target));
@@ -6052,7 +6166,7 @@ var lsCommand9 = new Command57("ls").description("list an org's members and thei
6052
6166
  await client.close();
6053
6167
  }
6054
6168
  });
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) => {
6169
+ var addCommand2 = new Command58("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
6170
  const client = await cloudClientFor(cmd.optsWithGlobals());
6057
6171
  try {
6058
6172
  const slug = orgFor(opts, client.target);
@@ -6062,7 +6176,7 @@ var addCommand2 = new Command57("add").description("add a user to an org (admins
6062
6176
  await client.close();
6063
6177
  }
6064
6178
  });
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) => {
6179
+ var rmCommand7 = new Command58("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
6180
  const client = await cloudClientFor(cmd.optsWithGlobals());
6067
6181
  try {
6068
6182
  const slug = orgFor(opts, client.target);
@@ -6078,11 +6192,11 @@ var rmCommand7 = new Command57("rm").description("remove a member (or leave: rem
6078
6192
  await client.close();
6079
6193
  }
6080
6194
  });
6081
- var membersCommand = new Command57("members").description("who is in an org and what they may do").addCommand(lsCommand9).addCommand(addCommand2).addCommand(rmCommand7);
6195
+ var membersCommand = new Command58("members").description("who is in an org and what they may do").addCommand(lsCommand9).addCommand(addCommand2).addCommand(rmCommand7);
6082
6196
 
6083
6197
  // 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) => {
6198
+ import { Command as Command59 } from "commander";
6199
+ var newCommand3 = new Command59("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
6200
  const client = await cloudClientFor(cmd.optsWithGlobals());
6087
6201
  try {
6088
6202
  const org = await client.createOrg({ slug, name: opts.name ?? slug });
@@ -6098,8 +6212,8 @@ var newCommand3 = new Command58("new").description("create an org; you become it
6098
6212
  });
6099
6213
 
6100
6214
  // 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) => {
6215
+ import { Command as Command60 } from "commander";
6216
+ var rmCommand8 = new Command60("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
6217
  if (!await confirm(`Delete org ${slug}? Its members lose access; its slug stays taken.`, opts.yes ?? false)) {
6104
6218
  info("cancelled");
6105
6219
  process.exitCode = 1;
@@ -6115,8 +6229,8 @@ var rmCommand8 = new Command59("rm").description("delete an org (owners only; re
6115
6229
  });
6116
6230
 
6117
6231
  // 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) => {
6232
+ import { Argument, Command as Command61 } from "commander";
6233
+ var roleCommand = new Command61("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
6234
  const client = await cloudClientFor(cmd.optsWithGlobals());
6121
6235
  try {
6122
6236
  const slug = orgFor(opts, client.target);
@@ -6128,11 +6242,11 @@ var roleCommand = new Command60("role").description("change a member's role (own
6128
6242
  });
6129
6243
 
6130
6244
  // 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);
6245
+ var orgCommand = new Command62("org").description("orgs: shared slugs that own boxes, with owners, admins and members").addCommand(lsCommand8).addCommand(newCommand3).addCommand(membersCommand).addCommand(roleCommand).addCommand(rmCommand8);
6132
6246
 
6133
6247
  // 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) => {
6248
+ import { Command as Command63 } from "commander";
6249
+ var usageCommand2 = new Command63("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
6250
  for (const [name, value] of [
6137
6251
  ["since", opts.since],
6138
6252
  ["until", opts.until]
@@ -6329,8 +6443,8 @@ function userRows(r) {
6329
6443
  }
6330
6444
 
6331
6445
  // 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) => {
6446
+ import { Command as Command64 } from "commander";
6447
+ var creditCommand = new Command64("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
6448
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
6335
6449
  try {
6336
6450
  if (client.target.kind === "local") throw new KvboxError("credit lives on the control plane: kvbox login first");
@@ -6359,8 +6473,8 @@ function creditRow(b, me2) {
6359
6473
  }
6360
6474
 
6361
6475
  // 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) => {
6476
+ import { Command as Command65 } from "commander";
6477
+ var redeemCommand = new Command65("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
6478
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
6365
6479
  try {
6366
6480
  if (client.target.kind === "local") throw new KvboxError("codes are redeemed on the control plane: kvbox login first");
@@ -6380,12 +6494,12 @@ var redeemCommand = new Command64("redeem").description("redeem a promo code for
6380
6494
  // src/commands/deploy/index.ts
6381
6495
  import { access as access5, readFile as readFile7 } from "fs/promises";
6382
6496
  import { basename as basename2, resolve as resolve3 } from "path";
6383
- import { Command as Command65, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
6497
+ import { Command as Command66, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
6384
6498
 
6385
6499
  // src/commands/deploy/config.ts
6386
6500
  import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
6387
6501
  import { isAbsolute, join as join6, normalize, relative as relative2 } from "path";
6388
- import { z as z15 } from "zod";
6502
+ import { z as z16 } from "zod";
6389
6503
 
6390
6504
  // src/commands/deploy/templates/docker.ts
6391
6505
  import { readFile as readFile4 } from "fs/promises";
@@ -6809,21 +6923,21 @@ function detectTemplates(pkg, dir = NO_FACTS) {
6809
6923
  var DEPLOY_AUTO_HIBERNATE_SEC = 3600;
6810
6924
  var CONFIG_FILE = "kvbox.json";
6811
6925
  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"),
6926
+ var DeployConfigSchema = z16.object({
6927
+ template: z16.enum(TEMPLATE_IDS),
6928
+ name: z16.string().regex(BOX_NAME_RE, "1-12 chars, lowercase letters, digits and '-', starting with a letter or digit"),
6815
6929
  /** 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(),
6930
+ org: z16.string().regex(ORG_SLUG_RE, "not an org slug").optional(),
6817
6931
  /** The HTTPS name (`<subdomain>.kvbox.app`); absent when deploying to this machine's own host. */
6818
- subdomain: z15.string().check((ctx) => {
6932
+ subdomain: z16.string().check((ctx) => {
6819
6933
  const problem = subdomainProblem(ctx.value);
6820
6934
  if (problem) ctx.issues.push({ code: "custom", message: problem, input: ctx.value });
6821
6935
  }).optional(),
6822
- size: z15.enum(SIZE_NAMES).optional(),
6936
+ size: z16.enum(SIZE_NAMES).optional(),
6823
6937
  /** The build output directory, relative to the app; the template's default when absent. */
6824
- dist: z15.string().optional(),
6938
+ dist: z16.string().optional(),
6825
6939
  /** 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()
6940
+ port: z16.number().int().min(1).max(65535).optional()
6827
6941
  });
6828
6942
  var SERVICE_KEY_RE = /^[a-z][a-z0-9-]{0,19}$/;
6829
6943
  var RESERVED_SERVICE_KEYS = ["app", "agent", "init", "volumes"];
@@ -6835,43 +6949,43 @@ var POSTGRES_PORT = 5432;
6835
6949
  var POSTGRES_IMAGE = "postgres:17";
6836
6950
  var POSTGRES_ENV = "DATABASE_URL";
6837
6951
  var IMAGE_RE = /^[a-z0-9][a-z0-9._/:@-]*$/;
6838
- var ServiceSchema = z15.strictObject({
6839
- template: z15.enum([...TEMPLATE_IDS, POSTGRES]),
6952
+ var ServiceSchema = z16.strictObject({
6953
+ template: z16.enum([...TEMPLATE_IDS, POSTGRES]),
6840
6954
  /** The service's directory, relative to the one holding kvbox.json; every template but postgres has one. */
6841
- dir: z15.string().min(1).optional(),
6955
+ dir: z16.string().min(1).optional(),
6842
6956
  /** 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(),
6957
+ image: z16.string().regex(IMAGE_RE, "an image name like postgres:17").optional(),
6844
6958
  /** The volume (a key of `volumes`) a postgres service keeps its data on. */
6845
- volume: z15.string().optional(),
6959
+ volume: z16.string().optional(),
6846
6960
  /** The box variable a postgres service's URL is written to, `DATABASE_URL` when absent. */
6847
- env: z15.string().optional(),
6961
+ env: z16.string().optional(),
6848
6962
  /** 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(),
6963
+ context: z16.string().min(1).optional(),
6964
+ dist: z16.string().optional(),
6851
6965
  /**
6852
6966
  * A command run once per deploy in the service's new version (a docker service: in a container of
6853
6967
  * the new image; node, nextjs: in the new source, installed and built), with the box's variables,
6854
6968
  * before it replaces the running one. Migrations, mostly. A failing one stops that service's deploy.
6855
6969
  */
6856
- release: z15.string().optional(),
6970
+ release: z16.string().optional(),
6857
6971
  /** 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(),
6972
+ port: z16.number().int().min(1).max(65535).optional(),
6859
6973
  /** 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()
6974
+ paths: z16.array(z16.string().regex(ROUTE_RE, "a path like / or /api, no trailing slash")).min(1).optional()
6861
6975
  });
6862
- var StackConfigSchema = z15.strictObject({
6976
+ var StackConfigSchema = z16.strictObject({
6863
6977
  name: DeployConfigSchema.shape.name.optional(),
6864
6978
  org: DeployConfigSchema.shape.org,
6865
6979
  subdomain: DeployConfigSchema.shape.subdomain,
6866
6980
  size: DeployConfigSchema.shape.size,
6867
6981
  /** 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)
6982
+ volumes: z16.record(z16.string(), z16.string()).optional(),
6983
+ services: z16.record(z16.string(), ServiceSchema)
6870
6984
  });
6871
6985
  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;
6986
+ const mib2 = parseMib(text2);
6987
+ if (mib2 === void 0 || mib2 === 0 || mib2 % 1024 !== 0 || mib2 / 1024 > MAX_VOLUME_GIB) return void 0;
6988
+ return mib2 / 1024;
6875
6989
  }
6876
6990
  function stackServices(stack, defaultPort, exposed = /* @__PURE__ */ new Map()) {
6877
6991
  const services = [];
@@ -7244,16 +7358,16 @@ var PROXY = (port) => [
7244
7358
  "proxy_buffering off;",
7245
7359
  "proxy_read_timeout 3600s;"
7246
7360
  ];
7247
- var block3 = (head, body) => [` ${head} {`, ...body.map((l) => ` ${l}`), " }", ""];
7361
+ var block4 = (head, body) => [` ${head} {`, ...body.map((l) => ` ${l}`), " }", ""];
7248
7362
  function locations(service, path) {
7249
7363
  const dist = `/srv/app/${service.key}/dist`;
7250
7364
  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;`])];
7365
+ if (path === "/") return block4("location /", [`root ${dist};`, "try_files $uri $uri/ /index.html;"]);
7366
+ return [...block4(`location = ${path}`, [`return 301 ${path}/;`]), ...block4(`location ${path}/`, [`alias ${dist}/;`, `try_files $uri $uri/ ${path}/index.html;`])];
7253
7367
  }
7254
7368
  const proxy = PROXY(service.port);
7255
- if (path === "/") return block3("location /", proxy);
7256
- return [...block3(`location = ${path}`, proxy), ...block3(`location ${path}/`, proxy)];
7369
+ if (path === "/") return block4("location /", proxy);
7370
+ return [...block4(`location = ${path}`, proxy), ...block4(`location ${path}/`, proxy)];
7257
7371
  }
7258
7372
  function stackSite(services) {
7259
7373
  const routed = services.flatMap((s) => s.paths.map((path) => ({ service: s, path })));
@@ -7281,7 +7395,7 @@ function stackSite(services) {
7281
7395
  "",
7282
7396
  ...routed.flatMap((r) => locations(r.service, r.path)),
7283
7397
  // No service at the top: say so instead of nginx's own welcome page.
7284
- ...root ? [] : block3("location /", ["return 404;"]),
7398
+ ...root ? [] : block4("location /", ["return 404;"]),
7285
7399
  "}",
7286
7400
  ""
7287
7401
  ].join("\n");
@@ -7645,7 +7759,7 @@ async function readPackageJson(dir) {
7645
7759
  }
7646
7760
 
7647
7761
  // 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) => {
7762
+ var deployCommand = new Command66("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
7763
  const dir = resolve3(dirArg ?? ".");
7650
7764
  const pkg = await readPackageJson2(dir);
7651
7765
  const facts = { indexHtml: await exists2(resolve3(dir, "index.html")), dockerfile: await exists2(resolve3(dir, "Dockerfile")) };
@@ -7802,15 +7916,15 @@ async function settle2(dir, pkg, facts, saved, opts, orgFlag, cloud) {
7802
7916
  }
7803
7917
 
7804
7918
  // src/commands/volume/index.ts
7805
- import { Command as Command78 } from "commander";
7919
+ import { Command as Command79 } from "commander";
7806
7920
 
7807
7921
  // src/commands/volume/attach.ts
7808
- import { Command as Command66 } from "commander";
7922
+ import { Command as Command67 } from "commander";
7809
7923
  function describeMount(machine, volume2, box2) {
7810
7924
  const path = machine.volumes?.find((v) => volume2 === v.name || volume2.endsWith(`/${v.name}`))?.mountPath ?? volumeMountPath(volume2.slice(volume2.lastIndexOf("/") + 1));
7811
7925
  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
7926
  }
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) => {
7927
+ var attachCommand = new Command67("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
7928
  if (volumeArg === void 0 || boxArg === void 0) askOrUsage("give the volume and the box: kvbox volume attach <volume> <box>");
7815
7929
  const client = await clientFor(cmd.optsWithGlobals());
7816
7930
  try {
@@ -7829,11 +7943,11 @@ var attachCommand = new Command66("attach").description("attach a volume to a bo
7829
7943
  });
7830
7944
 
7831
7945
  // src/commands/volume/backup/index.ts
7832
- import { Command as Command72 } from "commander";
7946
+ import { Command as Command73 } from "commander";
7833
7947
 
7834
7948
  // 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) => {
7949
+ import { Command as Command68 } from "commander";
7950
+ var createCommand4 = new Command68("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
7951
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7838
7952
  try {
7839
7953
  requireCloud3(client);
@@ -7860,8 +7974,8 @@ var createCommand4 = new Command67("create").description("back up a volume's dis
7860
7974
  });
7861
7975
 
7862
7976
  // 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) => {
7977
+ import { Command as Command69 } from "commander";
7978
+ var lsCommand10 = new Command69("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
7979
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7866
7980
  try {
7867
7981
  requireCloud3(client);
@@ -7894,8 +8008,8 @@ var lsCommand10 = new Command68("ls").alias("list").description("list volume bac
7894
8008
  });
7895
8009
 
7896
8010
  // 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) => {
8011
+ import { Command as Command70 } from "commander";
8012
+ var restoreCommand2 = new Command70("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
8013
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7900
8014
  try {
7901
8015
  requireCloud3(client);
@@ -7918,8 +8032,8 @@ var restoreCommand2 = new Command69("restore").description("put a backup back: t
7918
8032
  });
7919
8033
 
7920
8034
  // 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) => {
8035
+ import { Command as Command71 } from "commander";
8036
+ var rmCommand9 = new Command71("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
8037
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7924
8038
  try {
7925
8039
  requireCloud3(client);
@@ -7930,9 +8044,9 @@ var rmCommand9 = new Command70("rm").alias("remove").description("remove a backu
7930
8044
  });
7931
8045
 
7932
8046
  // src/commands/volume/backup/schedule.ts
7933
- import { Command as Command71 } from "commander";
8047
+ import { Command as Command72 } from "commander";
7934
8048
  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")
8049
+ new Command72("schedule").description("show or switch a volume's nightly backup (daily, UTC; off until you turn it on)").argument("<volume>", "volume name")
7936
8050
  ).action(async (volume2, flags, cmd) => {
7937
8051
  const change = changeOf(flags);
7938
8052
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
@@ -7948,15 +8062,15 @@ var scheduleCommand2 = scheduleFlags(
7948
8062
  });
7949
8063
 
7950
8064
  // 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);
8065
+ var backupCommand2 = new Command73("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
8066
  for (const cmd of backupCommand2.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
7953
8067
 
7954
8068
  // src/commands/volume/create.ts
7955
- import { Command as Command73 } from "commander";
8069
+ import { Command as Command74 } from "commander";
7956
8070
  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;
8071
+ const mib2 = parseMib(text2);
8072
+ if (mib2 === void 0 || mib2 % 1024 !== 0) throw new KvboxError(`${label} ${text2}: write whole GB, like 50 or 50GB`);
8073
+ const gib = mib2 / 1024;
7960
8074
  if (gib > MAX_VOLUME_GIB) throw new KvboxError(`${label} ${text2}: a volume is at most ${MAX_VOLUME_GIB} GB`);
7961
8075
  return gib;
7962
8076
  }
@@ -7968,7 +8082,7 @@ function sizeProblem(answer) {
7968
8082
  return err instanceof KvboxError ? err.message.replace(/^--size \S+: /, "") : String(err);
7969
8083
  }
7970
8084
  }
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) => {
8085
+ var createCommand5 = new Command74("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
8086
  const ask = interactive();
7973
8087
  if (nameArg === void 0 || opts.size === void 0) askOrUsage("give the name and the size: kvbox volume create <name> --size <gb> --box <box>");
7974
8088
  const name = nameArg ?? await text("Volume name", { validate: (a) => VOLUME_NAME_RE.test(a) ? void 0 : VOLUME_NAME_RULE });
@@ -8001,8 +8115,8 @@ var createCommand5 = new Command73("create").alias("new").description("create a
8001
8115
  });
8002
8116
 
8003
8117
  // 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) => {
8118
+ import { Command as Command75 } from "commander";
8119
+ var detachCommand = new Command75("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
8120
  if (volumeArg === void 0) askOrUsage("give the volume: kvbox volume detach <volume> [box]");
8007
8121
  const client = await clientFor(cmd.optsWithGlobals());
8008
8122
  try {
@@ -8027,8 +8141,8 @@ var detachCommand = new Command74("detach").description("detach a volume from a
8027
8141
  });
8028
8142
 
8029
8143
  // 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) => {
8144
+ import { Command as Command76 } from "commander";
8145
+ var growCommand = new Command76("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
8146
  const sizeGib = parseGib2(size, "size");
8033
8147
  const client = await clientFor(cmd.optsWithGlobals());
8034
8148
  try {
@@ -8041,8 +8155,8 @@ var growCommand = new Command75("grow").alias("resize").description("make a volu
8041
8155
  });
8042
8156
 
8043
8157
  // 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) => {
8158
+ import { Command as Command77 } from "commander";
8159
+ var lsCommand11 = new Command77("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
8160
  const client = await clientFor(cmd.optsWithGlobals());
8047
8161
  try {
8048
8162
  const cloud = client.target.kind === "cloud";
@@ -8073,8 +8187,8 @@ var lsCommand11 = new Command76("ls").alias("list").description("list volumes: s
8073
8187
  });
8074
8188
 
8075
8189
  // 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) => {
8190
+ import { Command as Command78 } from "commander";
8191
+ var rmCommand10 = new Command78("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
8192
  if (!await confirm(`Delete volume ${name} and everything on it?`, opts.yes ?? false)) {
8079
8193
  info("cancelled");
8080
8194
  process.exitCode = 1;
@@ -8090,18 +8204,18 @@ var rmCommand10 = new Command77("rm").alias("remove").description("delete a volu
8090
8204
  });
8091
8205
 
8092
8206
  // 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);
8207
+ var volumeCommand = new Command79("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
8208
  for (const cmd of volumeCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
8095
8209
  volumeCommand.addCommand(backupCommand2);
8096
8210
 
8097
8211
  // src/commands/bucket/index.ts
8098
- import { Command as Command95 } from "commander";
8212
+ import { Command as Command96 } from "commander";
8099
8213
 
8100
8214
  // src/commands/bucket/backup/index.ts
8101
- import { Command as Command84 } from "commander";
8215
+ import { Command as Command85 } from "commander";
8102
8216
 
8103
8217
  // src/commands/bucket/backup/create.ts
8104
- import { Command as Command79 } from "commander";
8218
+ import { Command as Command80 } from "commander";
8105
8219
 
8106
8220
  // src/commands/bucket/shared.ts
8107
8221
  async function bucketClient(cmd) {
@@ -8127,7 +8241,7 @@ function printRows(rows2) {
8127
8241
  }
8128
8242
 
8129
8243
  // 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) => {
8244
+ var createCommand6 = new Command80("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
8245
  const client = await bucketClient(cmd);
8132
8246
  const ls = "kvbox bucket backup ls";
8133
8247
  try {
@@ -8155,8 +8269,8 @@ var createCommand6 = new Command79("create").description("back up your object st
8155
8269
  });
8156
8270
 
8157
8271
  // 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) => {
8272
+ import { Command as Command81 } from "commander";
8273
+ var lsCommand12 = new Command81("ls").alias("list").description("list the backups of your object storage").option("--json", "print as JSON").action(async (opts, cmd) => {
8160
8274
  const client = await bucketClient(cmd);
8161
8275
  try {
8162
8276
  const list = await client.storageBackups();
@@ -8188,8 +8302,8 @@ var lsCommand12 = new Command80("ls").alias("list").description("list the backup
8188
8302
  });
8189
8303
 
8190
8304
  // 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) => {
8305
+ import { Command as Command82 } from "commander";
8306
+ var restoreCommand3 = new Command82("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
8307
  const client = await bucketClient(cmd);
8194
8308
  try {
8195
8309
  const backup = await client.storageBackup(id);
@@ -8219,8 +8333,8 @@ var restoreCommand3 = new Command81("restore").description("put a backup back: e
8219
8333
  });
8220
8334
 
8221
8335
  // 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) => {
8336
+ import { Command as Command83 } from "commander";
8337
+ var rmCommand11 = new Command83("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
8338
  const client = await bucketClient(cmd);
8225
8339
  try {
8226
8340
  const backup = (await client.storageBackups()).find((b) => b.id === id);
@@ -8239,8 +8353,8 @@ var rmCommand11 = new Command82("rm").alias("remove").description("remove a back
8239
8353
  });
8240
8354
 
8241
8355
  // 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(
8356
+ import { Command as Command84 } from "commander";
8357
+ var scheduleCommand3 = scheduleFlags(new Command84("schedule").description("show or switch the nightly backup of your object storage (daily, UTC; off until you turn it on)")).action(
8244
8358
  async (flags, cmd) => {
8245
8359
  const change = changeOf(flags);
8246
8360
  const client = await bucketClient(cmd);
@@ -8256,11 +8370,11 @@ var scheduleCommand3 = scheduleFlags(new Command83("schedule").description("show
8256
8370
  );
8257
8371
 
8258
8372
  // 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);
8373
+ var backupCommand3 = new Command85("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
8374
 
8261
8375
  // 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) => {
8376
+ import { Command as Command86 } from "commander";
8377
+ var createCommand7 = new Command86("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
8378
  const sizeGib = opts.size === void 0 ? void 0 : parseGib2(opts.size);
8265
8379
  const client = await bucketClient(cmd);
8266
8380
  try {
@@ -8280,8 +8394,8 @@ var createCommand7 = new Command85("create").description("make a bucket (the fir
8280
8394
  });
8281
8395
 
8282
8396
  // 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) => {
8397
+ import { Command as Command87 } from "commander";
8398
+ var growCommand2 = new Command87("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
8399
  const sizeGib = parseGib2(size, "size");
8286
8400
  const client = await bucketClient(cmd);
8287
8401
  try {
@@ -8294,8 +8408,8 @@ var growCommand2 = new Command86("grow").description("make your object storage l
8294
8408
  });
8295
8409
 
8296
8410
  // 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) => {
8411
+ import { Command as Command88 } from "commander";
8412
+ var infoCommand = new Command88("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
8413
  const client = await bucketClient(cmd);
8300
8414
  try {
8301
8415
  const b = await client.getBucket(name);
@@ -8325,11 +8439,11 @@ with the AWS CLI: aws s3 ls s3://${b.name} --endpoint-url ${b.endpoint}`));
8325
8439
  });
8326
8440
 
8327
8441
  // src/commands/bucket/key/index.ts
8328
- import { Command as Command91 } from "commander";
8442
+ import { Command as Command92 } from "commander";
8329
8443
 
8330
8444
  // 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) => {
8445
+ import { Command as Command89 } from "commander";
8446
+ var createCommand8 = new Command89("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
8447
  const client = await bucketClient(cmd);
8334
8448
  try {
8335
8449
  const key = await client.createBucketKey(bucket, { ...opts.name !== void 0 ? { name: opts.name } : {}, ...opts.readOnly ? { readOnly: true } : {} });
@@ -8352,8 +8466,8 @@ var createCommand8 = new Command88("create").description("make an access key for
8352
8466
  });
8353
8467
 
8354
8468
  // 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) => {
8469
+ import { Command as Command90 } from "commander";
8470
+ var lsCommand13 = new Command90("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
8471
  const client = await bucketClient(cmd);
8358
8472
  try {
8359
8473
  const keys = await client.listBucketKeys(bucket);
@@ -8372,8 +8486,8 @@ var lsCommand13 = new Command89("ls").alias("list").description("list a bucket's
8372
8486
  });
8373
8487
 
8374
8488
  // 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) => {
8489
+ import { Command as Command91 } from "commander";
8490
+ var rmCommand12 = new Command91("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
8491
  const client = await bucketClient(cmd);
8378
8492
  try {
8379
8493
  if (!await confirm(`Delete key ${id} of bucket ${bucket}? Whatever uses it stops working.`, opts.yes ?? false)) {
@@ -8389,11 +8503,11 @@ var rmCommand12 = new Command90("rm").alias("remove").description("delete an acc
8389
8503
  });
8390
8504
 
8391
8505
  // 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);
8506
+ var keyCommand2 = new Command92("key").aliases(["keys"]).description("access keys of a bucket: what your app signs in with").addCommand(createCommand8).addCommand(lsCommand13).addCommand(rmCommand12);
8393
8507
 
8394
8508
  // 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) => {
8509
+ import { Command as Command93 } from "commander";
8510
+ var lsCommand14 = new Command93("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
8511
  const client = await bucketClient(cmd);
8398
8512
  try {
8399
8513
  const buckets = await client.listBuckets({ all: opts.all });
@@ -8424,8 +8538,8 @@ var lsCommand14 = new Command92("ls").alias("list").description("list buckets, a
8424
8538
  });
8425
8539
 
8426
8540
  // 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) => {
8541
+ import { Command as Command94 } from "commander";
8542
+ var publicCommand = new Command94("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
8543
  if (state !== "on" && state !== "off") throw new KvboxError(`"${state}": say on or off`);
8430
8544
  const on = state === "on";
8431
8545
  if (!on && opts.sub !== void 0) throw new KvboxError("--sub goes with on");
@@ -8453,8 +8567,8 @@ var publicCommand = new Command93("public").description("let anyone read a bucke
8453
8567
  });
8454
8568
 
8455
8569
  // 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) => {
8570
+ import { Command as Command95 } from "commander";
8571
+ var rmCommand13 = new Command95("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
8572
  const client = await bucketClient(cmd);
8459
8573
  try {
8460
8574
  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 +8587,7 @@ var rmCommand13 = new Command94("rm").alias("remove").description("delete an emp
8473
8587
  });
8474
8588
 
8475
8589
  // 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);
8590
+ var bucketCommand = new Command96("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
8591
  var withOrg2 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal buckets)");
8478
8592
  for (const cmd of bucketCommand.commands) {
8479
8593
  if (cmd === keyCommand2 || cmd === backupCommand3) cmd.commands.forEach(withOrg2);
@@ -8481,10 +8595,10 @@ for (const cmd of bucketCommand.commands) {
8481
8595
  }
8482
8596
 
8483
8597
  // src/commands/cron/index.ts
8484
- import { Command as Command108 } from "commander";
8598
+ import { Command as Command109 } from "commander";
8485
8599
 
8486
8600
  // src/commands/cron/create.ts
8487
- import { Command as Command96 } from "commander";
8601
+ import { Command as Command97 } from "commander";
8488
8602
 
8489
8603
  // src/commands/cron/shared.ts
8490
8604
  async function cronClient(cmd) {
@@ -8545,7 +8659,7 @@ function printRows2(rows2) {
8545
8659
  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
8660
 
8547
8661
  // 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) => {
8662
+ var createCommand9 = new Command97("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
8663
  const client = await cronClient(cmd);
8550
8664
  try {
8551
8665
  const service = await client.createCronService(name);
@@ -8562,8 +8676,8 @@ var createCommand9 = new Command96("create").description("make a cron service: a
8562
8676
  });
8563
8677
 
8564
8678
  // 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) => {
8679
+ import { Command as Command98 } from "commander";
8680
+ var infoCommand2 = new Command98("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
8681
  const client = await cronClient(cmd);
8568
8682
  try {
8569
8683
  const service = await client.getCronService(name);
@@ -8587,8 +8701,8 @@ var infoCommand2 = new Command97("info").alias("get").description("show a cron s
8587
8701
  });
8588
8702
 
8589
8703
  // 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) => {
8704
+ import { Command as Command99 } from "commander";
8705
+ var lsCommand15 = new Command99("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
8706
  const client = await cronClient(cmd);
8593
8707
  try {
8594
8708
  const services = await client.listCronServices({ all: opts.all });
@@ -8608,8 +8722,8 @@ var lsCommand15 = new Command98("ls").alias("list").description("list cron servi
8608
8722
  });
8609
8723
 
8610
8724
  // 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) => {
8725
+ import { Command as Command100 } from "commander";
8726
+ var rmCommand14 = new Command100("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
8727
  const client = await cronClient(cmd);
8614
8728
  try {
8615
8729
  if (!await confirm(`Delete cron service ${name}? Its triggers stop firing and their run history is deleted.`, opts.yes ?? false)) {
@@ -8625,10 +8739,10 @@ var rmCommand14 = new Command99("rm").alias("remove").description("delete a cron
8625
8739
  });
8626
8740
 
8627
8741
  // src/commands/cron/trigger/index.ts
8628
- import { Command as Command107 } from "commander";
8742
+ import { Command as Command108 } from "commander";
8629
8743
 
8630
8744
  // src/commands/cron/trigger/add.ts
8631
- import { Command as Command100 } from "commander";
8745
+ import { Command as Command101 } from "commander";
8632
8746
  function portOf(value) {
8633
8747
  const n2 = Number(value);
8634
8748
  if (!Number.isInteger(n2) || n2 < 1 || n2 > 65535) throw new KvboxError(`--port ${value}: a port is a number from 1 to 65535`);
@@ -8648,7 +8762,7 @@ function timeoutOf(value) {
8648
8762
  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
8763
  return sec;
8650
8764
  }
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) => {
8765
+ var addCommand3 = new Command101("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
8766
  let action;
8653
8767
  if (opts.run !== void 0) {
8654
8768
  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 +8789,8 @@ var addCommand3 = new Command100("add").description("add a trigger: on a schedul
8675
8789
  });
8676
8790
 
8677
8791
  // 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) => {
8792
+ import { Command as Command102 } from "commander";
8793
+ var lsCommand16 = new Command102("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
8794
  const client = await cronClient(cmd);
8681
8795
  try {
8682
8796
  const triggers = await client.listCronTriggers(service);
@@ -8692,8 +8806,8 @@ var lsCommand16 = new Command101("ls").alias("list").description("list a cron se
8692
8806
  });
8693
8807
 
8694
8808
  // 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) => {
8809
+ import { Command as Command103 } from "commander";
8810
+ var pauseCommand2 = new Command103("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
8811
  const client = await cronClient(cmd);
8698
8812
  try {
8699
8813
  const trigger = await client.setCronTriggerEnabled(service, id, false);
@@ -8708,8 +8822,8 @@ var pauseCommand2 = new Command102("pause").description("stop a trigger from fir
8708
8822
  });
8709
8823
 
8710
8824
  // 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) => {
8825
+ import { Command as Command104 } from "commander";
8826
+ var resumeCommand2 = new Command104("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
8827
  const client = await cronClient(cmd);
8714
8828
  try {
8715
8829
  const trigger = await client.setCronTriggerEnabled(service, id, true);
@@ -8724,8 +8838,8 @@ var resumeCommand2 = new Command103("resume").description("let a paused trigger
8724
8838
  });
8725
8839
 
8726
8840
  // 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) => {
8841
+ import { Command as Command105 } from "commander";
8842
+ var rmCommand15 = new Command105("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
8843
  const client = await cronClient(cmd);
8730
8844
  try {
8731
8845
  if (!await confirm(`Delete trigger ${id} of cron service ${service}? Its run history is deleted too.`, opts.yes ?? false)) {
@@ -8741,8 +8855,8 @@ var rmCommand15 = new Command104("rm").alias("remove").description("delete a tri
8741
8855
  });
8742
8856
 
8743
8857
  // 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) => {
8858
+ import { Command as Command106 } from "commander";
8859
+ var runCommand = new Command106("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
8860
  const client = await cronClient(cmd);
8747
8861
  try {
8748
8862
  const trigger = await client.runCronTrigger(service, id);
@@ -8758,13 +8872,13 @@ var runCommand = new Command105("run").description("fire a trigger now, once, be
8758
8872
  });
8759
8873
 
8760
8874
  // src/commands/cron/trigger/runs.ts
8761
- import { Command as Command106 } from "commander";
8875
+ import { Command as Command107 } from "commander";
8762
8876
  function limitOf(value) {
8763
8877
  const n2 = Number(value);
8764
8878
  if (!Number.isInteger(n2) || n2 < 1) throw new KvboxError(`-n ${value}: a number of runs, 1 or more`);
8765
8879
  return n2;
8766
8880
  }
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) => {
8881
+ var runsCommand = new Command107("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
8882
  const limit = limitOf(opts.limit);
8769
8883
  const client = await cronClient(cmd);
8770
8884
  try {
@@ -8794,10 +8908,10 @@ var runsCommand = new Command106("runs").aliases(["logs"]).description("show how
8794
8908
  });
8795
8909
 
8796
8910
  // 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);
8911
+ var triggerCommand = new Command108("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
8912
 
8799
8913
  // 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);
8914
+ var cronCommand = new Command109("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
8915
  var withOrg3 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal cron services)");
8802
8916
  for (const cmd of cronCommand.commands) {
8803
8917
  if (cmd === triggerCommand) cmd.commands.forEach(withOrg3);
@@ -8805,13 +8919,13 @@ for (const cmd of cronCommand.commands) {
8805
8919
  }
8806
8920
 
8807
8921
  // src/commands/managed/kind.ts
8808
- import { Command as Command127 } from "commander";
8922
+ import { Command as Command128 } from "commander";
8809
8923
 
8810
8924
  // src/commands/managed/backup/index.ts
8811
- import { Command as Command115 } from "commander";
8925
+ import { Command as Command116 } from "commander";
8812
8926
 
8813
8927
  // src/commands/managed/backup/create.ts
8814
- import { Command as Command110 } from "commander";
8928
+ import { Command as Command111 } from "commander";
8815
8929
 
8816
8930
  // src/commands/managed/shared.ts
8817
8931
  import "commander";
@@ -8898,7 +9012,7 @@ function parseStorage(text2, flag) {
8898
9012
  }
8899
9013
 
8900
9014
  // 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) => {
9015
+ var createCommand10 = (spec) => new Command111("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
9016
  const client = await managedClient(cmd);
8903
9017
  const ls = `kvbox ${spec.command} backup ls ${name}`;
8904
9018
  try {
@@ -8925,7 +9039,7 @@ var createCommand10 = (spec) => new Command110("create").description("back up a
8925
9039
  });
8926
9040
 
8927
9041
  // src/commands/managed/backup/ls.ts
8928
- import { Command as Command111 } from "commander";
9042
+ import { Command as Command112 } from "commander";
8929
9043
  var lsCommand17 = (spec) => {
8930
9044
  const removedOnes = async (err, name, client) => {
8931
9045
  if (!(err instanceof CallError && err.status === 404)) throw err;
@@ -8934,7 +9048,7 @@ var lsCommand17 = (spec) => {
8934
9048
  const own = name.includes("/") ? [] : gone.filter((b) => b.owner === me(client));
8935
9049
  return own.length > 0 ? own : gone;
8936
9050
  };
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) => {
9051
+ return new Command112("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
9052
  const client = await managedClient(cmd);
8939
9053
  try {
8940
9054
  const list = name === void 0 ? await client.listManagedBackups(spec.kind) : await client.managedBackups(spec.kind, name).catch((err) => removedOnes(err, name, client));
@@ -8977,8 +9091,8 @@ var lsCommand17 = (spec) => {
8977
9091
  };
8978
9092
 
8979
9093
  // 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) => {
9094
+ import { Command as Command113 } from "commander";
9095
+ var restoreCommand4 = (spec) => new Command113("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
9096
  const client = await managedClient(cmd);
8983
9097
  try {
8984
9098
  const backup = await client.managedBackup(spec.kind, name, id);
@@ -9000,8 +9114,8 @@ var restoreCommand4 = (spec) => new Command112("restore").description("put a bac
9000
9114
  });
9001
9115
 
9002
9116
  // 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) => {
9117
+ import { Command as Command114 } from "commander";
9118
+ var rmCommand16 = (spec) => new Command114("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
9119
  const client = await managedClient(cmd);
9006
9120
  try {
9007
9121
  await removeListed(client, await client.listManagedBackups(spec.kind), (b) => b.name, name, id, `database ${name}`, opts.yes ?? false);
@@ -9011,8 +9125,8 @@ var rmCommand16 = (spec) => new Command113("rm").alias("remove").description("re
9011
9125
  });
9012
9126
 
9013
9127
  // 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(
9128
+ import { Command as Command115 } from "commander";
9129
+ var scheduleCommand4 = (spec) => scheduleFlags(new Command115("schedule").description("show or change when a database is backed up on its own (daily, UTC)").argument("<db>", "its name")).action(
9016
9130
  async (name, flags, cmd) => {
9017
9131
  const change = changeOf(flags);
9018
9132
  const client = await managedClient(cmd);
@@ -9028,18 +9142,18 @@ var scheduleCommand4 = (spec) => scheduleFlags(new Command114("schedule").descri
9028
9142
 
9029
9143
  // src/commands/managed/backup/index.ts
9030
9144
  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");
9145
+ const command = new Command116("backup").description("back up a database to the kvbox cloud, list backups, restore or remove one, or change its nightly schedule");
9032
9146
  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
9147
  return command;
9034
9148
  };
9035
9149
 
9036
9150
  // src/commands/managed/create.ts
9037
- import { Command as Command116 } from "commander";
9151
+ import { Command as Command117 } from "commander";
9038
9152
  import { setTimeout as sleep5 } from "timers/promises";
9039
9153
  var READY_WAIT_MS = 9e4;
9040
9154
  var READY_STEP_MS = 2e3;
9041
9155
  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");
9156
+ const command = new Command117("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
9157
  for (const o of spec.options) command.option(`--${o.name} <${o.arg}>`, o.help);
9044
9158
  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
9159
  const options = Object.fromEntries(spec.options.flatMap((o) => typeof opts[o.name] === "string" ? [[o.name, opts[o.name]]] : []));
@@ -9088,8 +9202,8 @@ var createCommand11 = (spec) => {
9088
9202
  };
9089
9203
 
9090
9204
  // 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) => {
9205
+ import { Command as Command118 } from "commander";
9206
+ var growCommand3 = (spec) => new Command118("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
9207
  const storageGib = parseStorage(size, "size");
9094
9208
  const client = await managedClient(cmd);
9095
9209
  try {
@@ -9102,8 +9216,8 @@ var growCommand3 = (spec) => new Command117("grow").description("give a database
9102
9216
  });
9103
9217
 
9104
9218
  // 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) => {
9219
+ import { Command as Command119 } from "commander";
9220
+ var infoCommand3 = (spec) => new Command119("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
9221
  const client = await managedClient(cmd);
9108
9222
  try {
9109
9223
  const m = await client.getManaged(spec.kind, name);
@@ -9115,8 +9229,8 @@ var infoCommand3 = (spec) => new Command118("info").alias("get").description("sh
9115
9229
  });
9116
9230
 
9117
9231
  // 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) => {
9232
+ import { Command as Command120 } from "commander";
9233
+ var linkCommand2 = (spec) => new Command120("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
9234
  const client = await managedClient(cmd);
9121
9235
  try {
9122
9236
  const m = await spin(`linking ${box2} to ${name}\u2026`, client.linkManaged(spec.kind, name, box2));
@@ -9132,7 +9246,7 @@ var linkCommand2 = (spec) => new Command119("link").description("let a box reach
9132
9246
  });
9133
9247
 
9134
9248
  // src/commands/managed/ls.ts
9135
- import { Command as Command120 } from "commander";
9249
+ import { Command as Command121 } from "commander";
9136
9250
  function listRows(items, user, kindColumn) {
9137
9251
  return items.map((m) => ({
9138
9252
  owner: m.owner === user ? "private" : m.owner,
@@ -9146,7 +9260,7 @@ function listRows(items, user, kindColumn) {
9146
9260
  created: age(m.createdAt)
9147
9261
  }));
9148
9262
  }
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) => {
9263
+ var lsCommand18 = (spec) => new Command121("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
9264
  const client = await managedClient(cmd);
9151
9265
  try {
9152
9266
  const items = await client.listManaged(spec?.kind, { all: opts.all });
@@ -9166,8 +9280,8 @@ var lsCommand18 = (spec) => new Command120("ls").alias("list").description(spec
9166
9280
  });
9167
9281
 
9168
9282
  // 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) => {
9283
+ import { Command as Command122 } from "commander";
9284
+ var passwordCommand = (spec) => new Command122("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
9285
  const client = await managedClient(cmd);
9172
9286
  try {
9173
9287
  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 +9297,8 @@ var passwordCommand = (spec) => new Command121("password").description("show a d
9183
9297
  });
9184
9298
 
9185
9299
  // 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) => {
9300
+ import { Command as Command123 } from "commander";
9301
+ var publicCommand2 = (spec) => new Command123("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
9302
  if (state !== "on" && state !== "off") throw new KvboxError(`write on or off: kvbox ${spec.command} public ${name} on`);
9189
9303
  const client = await managedClient(cmd);
9190
9304
  try {
@@ -9205,8 +9319,8 @@ var publicCommand2 = (spec) => new Command122("public").description("open a data
9205
9319
  });
9206
9320
 
9207
9321
  // 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) => {
9322
+ import { Command as Command124 } from "commander";
9323
+ var rmCommand17 = (spec) => new Command124("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
9324
  const client = await managedClient(cmd);
9211
9325
  try {
9212
9326
  if (!await confirm(`Delete database ${name} and all its data? There is no backup.`, opts.yes ?? false)) {
@@ -9222,8 +9336,8 @@ var rmCommand17 = (spec) => new Command123("rm").alias("remove").description("de
9222
9336
  });
9223
9337
 
9224
9338
  // 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) => {
9339
+ import { Command as Command125 } from "commander";
9340
+ var startCommand2 = (spec) => new Command125("start").description("run a stopped database again").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
9227
9341
  const client = await managedClient(cmd);
9228
9342
  try {
9229
9343
  const m = await spin(`starting ${name}\u2026`, client.startManaged(spec.kind, name));
@@ -9235,8 +9349,8 @@ var startCommand2 = (spec) => new Command124("start").description("run a stopped
9235
9349
  });
9236
9350
 
9237
9351
  // 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) => {
9352
+ import { Command as Command126 } from "commander";
9353
+ var stopCommand2 = (spec) => new Command126("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
9354
  const client = await managedClient(cmd);
9241
9355
  try {
9242
9356
  const m = await spin(`stopping ${name}\u2026`, client.stopManaged(spec.kind, name));
@@ -9248,8 +9362,8 @@ var stopCommand2 = (spec) => new Command125("stop").description("shut a database
9248
9362
  });
9249
9363
 
9250
9364
  // 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) => {
9365
+ import { Command as Command127 } from "commander";
9366
+ var unlinkCommand2 = (spec) => new Command127("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
9367
  const client = await managedClient(cmd);
9254
9368
  try {
9255
9369
  const m = await spin(`unlinking ${box2} from ${name}\u2026`, client.unlinkManaged(spec.kind, name, box2));
@@ -9262,7 +9376,7 @@ var unlinkCommand2 = (spec) => new Command126("unlink").description("stop a box
9262
9376
 
9263
9377
  // src/commands/managed/kind.ts
9264
9378
  function kindCommand(spec, description) {
9265
- const command = new Command127(spec.command).aliases(spec.aliases).description(description);
9379
+ const command = new Command128(spec.command).aliases(spec.aliases).description(description);
9266
9380
  for (const make of [createCommand11, lsCommand18, infoCommand3, passwordCommand, publicCommand2, linkCommand2, unlinkCommand2, growCommand3, stopCommand2, startCommand2, rmCommand17]) {
9267
9381
  command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
9268
9382
  }
@@ -9277,14 +9391,14 @@ var pgCommand = kindCommand(POSTGRES2, "managed PostgreSQL: a database kvbox run
9277
9391
  var redisCommand = kindCommand(REDIS, "managed Redis (Valkey): a Redis kvbox runs for you, private until you link a box or make it public");
9278
9392
 
9279
9393
  // 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)"));
9394
+ import { Command as Command129 } from "commander";
9395
+ var managedCommand = new Command129("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
9396
 
9283
9397
  // src/commands/env/index.ts
9284
- import { Command as Command132 } from "commander";
9398
+ import { Command as Command133 } from "commander";
9285
9399
 
9286
9400
  // src/commands/env/ls.ts
9287
- import { Command as Command129 } from "commander";
9401
+ import { Command as Command130 } from "commander";
9288
9402
 
9289
9403
  // src/commands/env/shared.ts
9290
9404
  function requireCloud4(client) {
@@ -9311,7 +9425,7 @@ function firstBootHint(box2, name) {
9311
9425
  }
9312
9426
 
9313
9427
  // 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) => {
9428
+ var lsCommand19 = new Command130("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
9429
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
9316
9430
  try {
9317
9431
  if (opts.box !== void 0) {
@@ -9350,8 +9464,8 @@ var lsCommand19 = new Command129("ls").alias("list").description("list the varia
9350
9464
  });
9351
9465
 
9352
9466
  // 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) => {
9467
+ import { Command as Command131 } from "commander";
9468
+ var rmCommand18 = new Command131("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
9469
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
9356
9470
  try {
9357
9471
  const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
@@ -9388,8 +9502,8 @@ var rmCommand18 = new Command130("rm").alias("remove").description("remove varia
9388
9502
  });
9389
9503
 
9390
9504
  // 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) => {
9505
+ import { Command as Command132 } from "commander";
9506
+ var setCommand2 = new Command132("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
9507
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
9394
9508
  try {
9395
9509
  const owner = opts.box === void 0 ? requireCloud4(client) : void 0;
@@ -9426,14 +9540,14 @@ var setCommand2 = new Command131("set").description("add or change a variable; b
9426
9540
  });
9427
9541
 
9428
9542
  // 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);
9543
+ var envCommand = new Command133("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand19, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand18);
9430
9544
  for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
9431
9545
 
9432
9546
  // src/commands/domain/index.ts
9433
- import { Command as Command136 } from "commander";
9547
+ import { Command as Command137 } from "commander";
9434
9548
 
9435
9549
  // src/commands/domain/add.ts
9436
- import { Command as Command133 } from "commander";
9550
+ import { Command as Command134 } from "commander";
9437
9551
 
9438
9552
  // src/commands/domain/shared.ts
9439
9553
  function requireCloud5(client) {
@@ -9453,7 +9567,7 @@ function hostIn(name, zone) {
9453
9567
  }
9454
9568
 
9455
9569
  // 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) => {
9570
+ var addCommand4 = new Command134("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
9571
  const domain = assertDomain(domainArg.trim().toLowerCase());
9458
9572
  const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
9459
9573
  const client = await clientFor(cmd.optsWithGlobals());
@@ -9489,8 +9603,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
9489
9603
  });
9490
9604
 
9491
9605
  // 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) => {
9606
+ import { Command as Command135 } from "commander";
9607
+ var lsCommand20 = new Command135("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
9494
9608
  const client = await clientFor(cmd.optsWithGlobals());
9495
9609
  try {
9496
9610
  requireCloud5(client);
@@ -9519,8 +9633,8 @@ var lsCommand20 = new Command134("ls").alias("list").description("list your cust
9519
9633
  });
9520
9634
 
9521
9635
  // 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) => {
9636
+ import { Command as Command136 } from "commander";
9637
+ var rmCommand19 = new Command136("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
9638
  const domain = domainArg.trim().toLowerCase();
9525
9639
  const client = await clientFor(cmd.optsWithGlobals());
9526
9640
  try {
@@ -9541,7 +9655,7 @@ var rmCommand19 = new Command135("rm").alias("remove").description("stop serving
9541
9655
  });
9542
9656
 
9543
9657
  // 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);
9658
+ var domainCommand = new Command137("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand4).addCommand(lsCommand20).addCommand(rmCommand19);
9545
9659
  for (const cmd of domainCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
9546
9660
 
9547
9661
  // src/commands/update.ts
@@ -9549,7 +9663,7 @@ import { spawn as spawn8 } from "child_process";
9549
9663
  import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
9550
9664
  import { tmpdir } from "os";
9551
9665
  import { join as join9 } from "path";
9552
- import { Command as Command137 } from "commander";
9666
+ import { Command as Command138 } from "commander";
9553
9667
 
9554
9668
  // src/update.ts
9555
9669
  import { mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
@@ -9668,7 +9782,7 @@ function run2(cmd, args) {
9668
9782
  child.on("exit", (code, signal) => resolve4(code ?? (signal ? 1 : 0)));
9669
9783
  });
9670
9784
  }
9671
- var selfUpdateCommand = new Command137("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
9785
+ var selfUpdateCommand = new Command138("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
9672
9786
  suppressUpdateNotice();
9673
9787
  const inst = installerFor(process.platform, process.env["KVBOX_INSTALL_URL"] || INSTALL_BASE);
9674
9788
  let code;
@@ -9692,7 +9806,7 @@ var selfUpdateCommand = new Command137("update").description("update kvbox to th
9692
9806
  import { chmod as chmod2, mkdir as mkdir4, readFile as readFile9, writeFile as writeFile5 } from "fs/promises";
9693
9807
  import { homedir as homedir2 } from "os";
9694
9808
  import { dirname as dirname2, join as join11 } from "path";
9695
- import { Command as Command138 } from "commander";
9809
+ import { Command as Command139 } from "commander";
9696
9810
 
9697
9811
  // src/sshConfig.ts
9698
9812
  import { spawnSync as spawnSync4 } from "child_process";
@@ -9756,19 +9870,19 @@ async function windowsLauncher(kvbox, p) {
9756
9870
  const short = res.status === 0 ? res.stdout.trim() : "";
9757
9871
  return short !== "" && !/\s/.test(short) ? short : file;
9758
9872
  }
9759
- function spliceBlock(text2, block4) {
9873
+ function spliceBlock(text2, block5) {
9760
9874
  const eol = text2.includes("\r\n") ? "\r\n" : "\n";
9761
9875
  const lines = text2.split(/\r?\n/);
9762
9876
  const begin = lines.findIndex((l) => l.trim().startsWith("# BEGIN kvbox"));
9763
9877
  const end = begin === -1 ? -1 : lines.findIndex((l, i) => i > begin && l.trim() === END_MARK);
9764
- const add = block4 === void 0 ? [] : block4.split("\n");
9878
+ const add = block5 === void 0 ? [] : block5.split("\n");
9765
9879
  let out;
9766
9880
  if (begin !== -1 && end !== -1) {
9767
9881
  const after = lines.slice(end + 1);
9768
- if (block4 === void 0 && after[0] === "") after.shift();
9882
+ if (block5 === void 0 && after[0] === "") after.shift();
9769
9883
  out = [...lines.slice(0, begin), ...add, ...after];
9770
9884
  } else {
9771
- if (block4 === void 0) return text2;
9885
+ if (block5 === void 0) return text2;
9772
9886
  const rest = text2 === "" ? [] : ["", ...lines];
9773
9887
  out = [...add, ...rest];
9774
9888
  }
@@ -9776,6 +9890,18 @@ function spliceBlock(text2, block4) {
9776
9890
  if (joined !== "" && !joined.endsWith(eol)) joined += eol;
9777
9891
  return joined;
9778
9892
  }
9893
+ function listedHosts(text2) {
9894
+ const lines = text2.split(/\r?\n/);
9895
+ const begin = lines.findIndex((l) => l.trim().startsWith("# BEGIN kvbox"));
9896
+ if (begin === -1) return [];
9897
+ const hosts = [];
9898
+ for (const line of lines.slice(begin + 1)) {
9899
+ if (line.trim() === END_MARK) break;
9900
+ const m = /^Host\s+(\S+)\s*$/.exec(line.trim());
9901
+ if (m && m[1] !== "*") hosts.push(m[1]);
9902
+ }
9903
+ return hosts;
9904
+ }
9779
9905
  var idsFile = (p) => join10(p.ssh, "ssh-config.json");
9780
9906
  function namesHost(line, alias) {
9781
9907
  const field = line.trim().split(/\s+/)[0] ?? "";
@@ -9802,13 +9928,13 @@ async function forgetReplacedBox(alias, id, p) {
9802
9928
  }
9803
9929
 
9804
9930
  // 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) => {
9931
+ var sshConfigCommand = new Command139("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
9932
  const file = opts.file ?? join11(homedir2(), ".ssh", "config");
9807
9933
  const before = await readFile9(file, "utf8").catch((err) => {
9808
9934
  if (err.code === "ENOENT") return "";
9809
9935
  throw err;
9810
9936
  });
9811
- if (opts.remove) {
9937
+ if (opts.remove && boxes.length === 0) {
9812
9938
  const after = spliceBlock(before, void 0);
9813
9939
  const removed = after !== before;
9814
9940
  if (removed) await writeFile5(file, after);
@@ -9818,39 +9944,58 @@ var sshConfigCommand = new Command138("ssh-config").description("add your boxes
9818
9944
  }
9819
9945
  const globals = cmd.optsWithGlobals();
9820
9946
  const client = await clientFor(globals);
9821
- let hosts;
9947
+ let named;
9948
+ let all = [];
9822
9949
  try {
9823
9950
  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));
9951
+ named = await aliasesOf(client, boxes, opts.remove === true);
9952
+ if (boxes.length === 0) all = named;
9826
9953
  } finally {
9827
9954
  await client.close();
9828
9955
  }
9956
+ const listed = listedHosts(before);
9957
+ const hosts = boxes.length === 0 ? all : opts.remove ? listed.filter((h) => !named.includes(h)) : [.../* @__PURE__ */ new Set([...listed, ...named])];
9958
+ hosts.sort((a, b) => a.localeCompare(b));
9829
9959
  const p = paths();
9830
9960
  const kvbox = launcher();
9831
9961
  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 });
9962
+ const block5 = renderBlock({ kvbox, renewWith, local: globals.local === true, hosts, p });
9833
9963
  await mkdir4(dirname2(file), { recursive: true, mode: 448 });
9834
9964
  const fresh = before === "";
9835
- await writeFile5(file, spliceBlock(before, block4));
9965
+ await writeFile5(file, spliceBlock(before, block5));
9836
9966
  if (fresh) await chmod2(file, 384).catch(() => void 0);
9837
9967
  if (opts.json) return json({ file, removed: false, hosts });
9838
9968
  if (client.target.kind === "cloud" && client.target.env === true) {
9839
9969
  warn("KVBOX_TOKEN is set in this shell only: ssh started elsewhere (VS Code) uses your kvbox login instead");
9840
9970
  }
9841
9971
  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");
9972
+ if (opts.remove) info(`took ${named.join(", ")} off the list`);
9973
+ if (hosts.length === 0) info("VS Code lists no box; any <box>.kvbox still works with ssh");
9843
9974
  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}`);
9975
+ info(`VS Code lists: ${hosts.join(", ")}`);
9976
+ info(`connect with ${color.bold(`ssh ${hosts[0]}`)}, or in VS Code: Remote-SSH: Connect to Host\u2026 \u2192 ${hosts[0]}`);
9846
9977
  }
9847
- info(color.dim("a box made later works as <box>.kvbox right away; run this again to have VS Code list it"));
9978
+ info(color.dim("any other box works as <box>.kvbox too; kvbox ssh-config <box> adds it to the list"));
9848
9979
  });
9980
+ async function aliasesOf(client, boxes, gone) {
9981
+ const mine = me(client);
9982
+ const list = await client.listMachines();
9983
+ if (boxes.length === 0) return list.map((b) => sshAlias(b, mine));
9984
+ return boxes.map((name) => {
9985
+ const box2 = pickRef(list, name, mine);
9986
+ if (!box2 && gone) {
9987
+ const [slug, bare] = name.includes("/") ? name.split("/", 2) : [mine ?? "", name];
9988
+ return sshAlias({ name: bare, owner: slug }, mine);
9989
+ }
9990
+ if (!box2) throw new KvboxError(`box ${name}: not found (kvbox ls)`);
9991
+ return sshAlias(box2, mine);
9992
+ });
9993
+ }
9849
9994
 
9850
9995
  // src/commands/sshProxy.ts
9851
9996
  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) => {
9997
+ import { Command as Command140 } from "commander";
9998
+ var sshProxyCommand = new Command140("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
9999
  const ref = parseAlias(host);
9855
10000
  if (ref === void 0) throw new KvboxError(`${host}: not a kvbox name (<box>.kvbox or <box>.<org>.kvbox)`);
9856
10001
  const client = await clientFor(cmd.optsWithGlobals());
@@ -10012,7 +10157,7 @@ function installRootHelp(program) {
10012
10157
 
10013
10158
  // src/program.ts
10014
10159
  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();
10160
+ const program = new Command141("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
10161
  program.addCommand(vmCommand);
10017
10162
  program.addCommand(snapshotsCommand);
10018
10163
  program.addCommand(volumeCommand);