@kvbox/cli 0.6.17 → 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 Command138 } 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.17" : 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
@@ -1219,7 +1219,9 @@ var BackupUsageSchema = z2.object({
1219
1219
  ownerKind: z2.enum(["user", "org"]).optional(),
1220
1220
  /** How many paid backups turned ready in the window. */
1221
1221
  count: z2.number().int(),
1222
- cost: z2.object({ amount: z2.number(), currency: z2.string() })
1222
+ cost: z2.object({ amount: z2.number(), currency: z2.string() }),
1223
+ /** The part of `cost` that nightly backups someone switched on make up: it recurs, the rest is one-off. Absent when none. */
1224
+ nightlyCost: z2.number().optional()
1223
1225
  });
1224
1226
  var UsageDayItemSchema = z2.object({
1225
1227
  id: z2.string(),
@@ -1763,17 +1765,77 @@ import { setTimeout as sleep2 } from "timers/promises";
1763
1765
  import { Agent, request } from "undici";
1764
1766
 
1765
1767
  // ../sdk/src/machines.ts
1766
- import { z as z5 } from "zod";
1768
+ import { z as z6 } from "zod";
1767
1769
 
1768
- // ../shared/src/traffic.ts
1770
+ // ../shared/src/resources.ts
1769
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";
1770
1832
  var TRAFFIC_SLOT_MS = 5 * 6e4;
1771
1833
  var TRAFFIC_KEEP_DAYS = 7;
1772
1834
  var TRAFFIC_KEEP_MS = TRAFFIC_KEEP_DAYS * 864e5;
1773
1835
  var LATENCY_BUCKETS_MS = [5, 10, 25, 50, 100, 250, 500, 1e3, 2500, 5e3, 1e4, 3e4];
1774
1836
  var LATENCY_BUCKET_COUNT = LATENCY_BUCKETS_MS.length + 1;
1775
- var count = z4.number().int().nonnegative();
1776
- var figures = {
1837
+ var count = z5.number().int().nonnegative();
1838
+ var figures2 = {
1777
1839
  requests: count,
1778
1840
  s2xx: count,
1779
1841
  s3xx: count,
@@ -1788,28 +1850,28 @@ var figures = {
1788
1850
  p50Ms: count.nullable(),
1789
1851
  p95Ms: count.nullable()
1790
1852
  };
1791
- var TrafficPointSchema = z4.object({ at: z4.string(), ...figures });
1792
- var TrafficReportSchema = z4.object({
1793
- box: z4.string(),
1794
- owner: z4.string(),
1795
- since: z4.string(),
1796
- until: z4.string(),
1797
- 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(),
1798
1860
  /** The one host name asked for; null for all of the box's. */
1799
- host: z4.string().nullable(),
1861
+ host: z5.string().nullable(),
1800
1862
  /** Every host name of the box with traffic in the range, whatever `host` is: what a filter can offer. */
1801
- hosts: z4.array(z4.string()),
1802
- totals: z4.object(figures),
1803
- points: z4.array(TrafficPointSchema)
1863
+ hosts: z5.array(z5.string()),
1864
+ totals: z5.object(figures2),
1865
+ points: z5.array(TrafficPointSchema)
1804
1866
  });
1805
- var BoxTrafficSchema = z4.object({ box: z4.string(), owner: z4.string(), ...figures });
1806
- var TrafficOverviewSchema = z4.object({
1807
- since: z4.string(),
1808
- until: z4.string(),
1809
- stepMin: z4.number().int().positive(),
1810
- totals: z4.object(figures),
1811
- points: z4.array(TrafficPointSchema),
1812
- 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)
1813
1875
  });
1814
1876
 
1815
1877
  // ../sdk/src/errors.ts
@@ -1922,7 +1984,7 @@ var Machines = class {
1922
1984
  ports;
1923
1985
  /** Every box the caller can read (their own and their orgs'), sorted by owner then name. */
1924
1986
  list(opts = {}) {
1925
- 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 });
1926
1988
  }
1927
1989
  /**
1928
1990
  * One box, found in the listing (the API has no route for a single box). `slug/name` looks in that
@@ -1936,7 +1998,7 @@ var Machines = class {
1936
1998
  async find(name, orgOpt, timeoutMs) {
1937
1999
  const slash = name.indexOf("/");
1938
2000
  const [org, bare] = slash === -1 ? [orgOpt, name] : [name.slice(0, slash), name.slice(slash + 1)];
1939
- 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 });
1940
2002
  const named = listing.filter((m) => m.name === bare && (slash === -1 || slugOf2(m.owner) === org));
1941
2003
  if (named.length <= 1) {
1942
2004
  if (named[0] !== void 0) return named[0];
@@ -1970,7 +2032,7 @@ var Machines = class {
1970
2032
  }
1971
2033
  /** Remove the box and its disk. */
1972
2034
  async remove(name, opts = {}) {
1973
- 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 });
1974
2036
  }
1975
2037
  /** Boot a stopped box. */
1976
2038
  start(name, opts = {}) {
@@ -2113,6 +2175,15 @@ var Machines = class {
2113
2175
  traffic(name, opts = {}) {
2114
2176
  return this.transport.request("GET", box(name, `/traffic${trafficQuery(opts)}`), TrafficReportSchema, { org: opts.org });
2115
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
+ }
2116
2187
  };
2117
2188
  var iso = (d) => typeof d === "string" ? d : d.toISOString();
2118
2189
  function trafficQuery(opts) {
@@ -2137,7 +2208,7 @@ var slugOf2 = (owner) => {
2137
2208
  };
2138
2209
 
2139
2210
  // ../sdk/src/snapshots.ts
2140
- import { z as z6 } from "zod";
2211
+ import { z as z7 } from "zod";
2141
2212
  var Snapshots = class {
2142
2213
  constructor(transport) {
2143
2214
  this.transport = transport;
@@ -2145,19 +2216,19 @@ var Snapshots = class {
2145
2216
  transport;
2146
2217
  /** Every snapshot the caller can read. */
2147
2218
  list(opts = {}) {
2148
- 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 });
2149
2220
  }
2150
2221
  /** Snapshot box `req.box` as `req.name` (`replace`: retake one that exists). The box is paused while it is taken. */
2151
2222
  create(req, opts = {}) {
2152
2223
  return this.transport.request("POST", "/snapshots", SnapshotSchema, { body: req, org: opts.org });
2153
2224
  }
2154
2225
  async remove(name, opts = {}) {
2155
- 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 });
2156
2227
  }
2157
2228
  };
2158
2229
 
2159
2230
  // ../sdk/src/transport.ts
2160
- import { z as z7 } from "zod";
2231
+ import { z as z8 } from "zod";
2161
2232
  var Transport = class {
2162
2233
  baseUrl;
2163
2234
  org;
@@ -2231,7 +2302,7 @@ var Transport = class {
2231
2302
  }
2232
2303
  }
2233
2304
  };
2234
- var LooseApiErrorSchema = z7.object({ error: z7.string(), code: z7.string().optional() });
2305
+ var LooseApiErrorSchema = z8.object({ error: z8.string(), code: z8.string().optional() });
2235
2306
  function safeJson(text2) {
2236
2307
  try {
2237
2308
  return JSON.parse(text2);
@@ -2249,7 +2320,7 @@ function errorCode(err) {
2249
2320
  }
2250
2321
 
2251
2322
  // ../sdk/src/integrations.ts
2252
- import { z as z8 } from "zod";
2323
+ import { z as z9 } from "zod";
2253
2324
  var Integrations = class {
2254
2325
  constructor(transport) {
2255
2326
  this.transport = transport;
@@ -2257,12 +2328,12 @@ var Integrations = class {
2257
2328
  transport;
2258
2329
  /** Each readable slug's state for each integration (`org`: one org's), connected or not; never a credential. */
2259
2330
  list(opts = {}) {
2260
- 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 });
2261
2332
  }
2262
2333
  };
2263
2334
 
2264
2335
  // ../sdk/src/volumes.ts
2265
- import { z as z9 } from "zod";
2336
+ import { z as z10 } from "zod";
2266
2337
  var volume = (name, rest = "") => `/volumes/${encodeURIComponent(name)}${rest}`;
2267
2338
  var Volumes = class {
2268
2339
  constructor(transport) {
@@ -2270,7 +2341,7 @@ var Volumes = class {
2270
2341
  }
2271
2342
  transport;
2272
2343
  list(opts = {}) {
2273
- 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 });
2274
2345
  }
2275
2346
  /**
2276
2347
  * Make a volume of `sizeGib` GiB. Through the cloud `box` is required: the volume is made on that
@@ -2293,7 +2364,7 @@ var Volumes = class {
2293
2364
  }
2294
2365
  /** Remove the volume and its data; it must be detached first. */
2295
2366
  async remove(name, opts = {}) {
2296
- 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 });
2297
2368
  }
2298
2369
  };
2299
2370
 
@@ -2343,35 +2414,41 @@ var Kvbox = class {
2343
2414
  };
2344
2415
 
2345
2416
  // src/client.ts
2346
- import { z as z14 } from "zod";
2417
+ import { z as z15 } from "zod";
2347
2418
 
2348
2419
  // ../shared/src/usage.ts
2349
- import { z as z10 } from "zod";
2350
- var PricingSchema = z10.object({
2351
- currency: z10.string().min(1),
2352
- vcpuHour: z10.number().nonnegative(),
2353
- ramGibHour: z10.number().nonnegative(),
2354
- diskGibHour: z10.number().nonnegative(),
2355
- volumeHour: z10.number().nonnegative().default(0),
2356
- volumeGibHour: z10.number().nonnegative().default(0),
2357
- 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),
2358
2429
  /**
2359
2430
  * Object storage (#182): an hour of a slug's storage existing, whatever it holds, which covers its
2360
2431
  * hidden box and the first `storageIncludedGib` of its size; each GiB above that is `storageGibHour`.
2361
2432
  * A price list from before object storage charges nothing for it.
2362
2433
  */
2363
- storageHour: z10.number().nonnegative().default(0),
2364
- storageGibHour: z10.number().nonnegative().default(0),
2365
- 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),
2366
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. */
2367
- cronHour: z10.number().nonnegative().default(0),
2438
+ cronHour: z11.number().nonnegative().default(0),
2368
2439
  /**
2369
2440
  * One backup a person starts, of anything, charged once it is ready (decision "A backup taken by hand
2370
- * costs a flat price…"); a failed one and a scheduled one cost nothing. A price list from before it charges nothing.
2441
+ * costs a flat price…"); a failed one costs nothing. A price list from before it charges nothing.
2442
+ */
2443
+ backup: z11.number().nonnegative().default(0),
2444
+ /**
2445
+ * One nightly backup of a box, a volume or the object storage, charged once it is ready (decision "A nightly
2446
+ * backup you switch on is charged…"): their switch is off until someone turns it on. A managed database's
2447
+ * nightly backup, on from its creation, is included in its price. A price list from before it charges nothing.
2371
2448
  */
2372
- backup: z10.number().nonnegative().default(0)
2449
+ scheduledBackup: z11.number().nonnegative().default(0)
2373
2450
  });
2374
- var PriceListSchema = PricingSchema.extend({ welcomeCredit: z10.number().nonnegative() });
2451
+ var PriceListSchema = PricingSchema.extend({ welcomeCredit: z11.number().nonnegative() });
2375
2452
  var HOUR_MS = 36e5;
2376
2453
  var round = (n2, places) => Math.round(n2 * 10 ** places) / 10 ** places;
2377
2454
  function costOf(t, pricing) {
@@ -2399,86 +2476,86 @@ function sumUsage(items, pricing) {
2399
2476
  var DAY_MS = 24 * HOUR_MS;
2400
2477
 
2401
2478
  // ../shared/src/managed.ts
2402
- import { z as z11 } from "zod";
2403
- var PriceSchema = z11.object({ perMonth: z11.number(), storagePerMonth: z11.number(), currency: z11.string() });
2404
- 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({
2405
2482
  /** The kind, as in `/managed/<kind>`: `postgres`. */
2406
- kind: z11.string(),
2483
+ kind: z12.string(),
2407
2484
  /** The CLI command for it: `pg` (`kvbox pg create …`). */
2408
- command: z11.string(),
2409
- title: z11.string(),
2410
- description: z11.string(),
2485
+ command: z12.string(),
2486
+ title: z12.string(),
2487
+ description: z12.string(),
2411
2488
  /** The version a new one runs, as shown: `18`. */
2412
- version: z11.string(),
2489
+ version: z12.string(),
2413
2490
  /** The port a linked box reaches it on. */
2414
- port: z11.number().int(),
2491
+ port: z12.number().int(),
2415
2492
  /** The port `public on` opens behind a host port: `port` again unless the kind serves TLS on another. */
2416
- publicPort: z11.number().int(),
2493
+ publicPort: z12.number().int(),
2417
2494
  /** Its guide, as a URL. */
2418
- docs: z11.string().optional(),
2419
- 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() }),
2420
2497
  /**
2421
2498
  * What create takes of this kind alone, beside what every kind takes (name, password, storage, near): a
2422
2499
  * flag and a form field each, all optional, `default` in words.
2423
2500
  */
2424
- 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() })),
2425
2502
  /** A month of it running with the default storage, and each further GB of storage. */
2426
- price: PriceSchema.extend({ storageGibPerMonth: z11.number() }),
2503
+ price: PriceSchema.extend({ storageGibPerMonth: z12.number() }),
2427
2504
  /** Whether a host answering now can run it. */
2428
- available: z11.boolean()
2505
+ available: z12.boolean()
2429
2506
  });
2430
- var CreateManagedRequest = z11.object({
2431
- name: z11.string(),
2507
+ var CreateManagedRequest = z12.object({
2508
+ name: z12.string(),
2432
2509
  /** The kind's own options by name (its catalog entry lists them); the kind checks them. */
2433
- options: z11.record(z11.string(), z11.string()).optional(),
2434
- password: z11.string().optional(),
2435
- 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(),
2436
2513
  /** Place it on the host of this box, so the box can be linked to it. */
2437
- near: z11.string().optional(),
2514
+ near: z12.string().optional(),
2438
2515
  /**
2439
2516
  * A backup of a database of the same kind and major version, of the same account (#186): the new
2440
2517
  * service starts on its data, a removed service's included. Its settings (Postgres: database, user)
2441
2518
  * are the backup's; the password is the new one.
2442
2519
  */
2443
- fromBackup: z11.string().optional()
2520
+ fromBackup: z12.string().optional()
2444
2521
  });
2445
- var ManagedHealthSchema = z11.object({
2522
+ var ManagedHealthSchema = z12.object({
2446
2523
  /** Its first start has finished: it has set itself up on its storage. */
2447
- ready: z11.boolean(),
2524
+ ready: z12.boolean(),
2448
2525
  /** It accepts connections. */
2449
- accepting: z11.boolean(),
2450
- version: z11.string(),
2526
+ accepting: z12.boolean(),
2527
+ version: z12.string(),
2451
2528
  /** The storage volume: what is used of it and its size. */
2452
- storageUsedBytes: z11.number().optional(),
2453
- storageTotalBytes: z11.number().optional(),
2529
+ storageUsedBytes: z12.number().optional(),
2530
+ storageTotalBytes: z12.number().optional(),
2454
2531
  /** What else the kind reports, ready to show: `{title: "Connections", value: "3"}`. */
2455
- facts: z11.array(z11.object({ title: z11.string(), value: z11.string() }))
2532
+ facts: z12.array(z12.object({ title: z12.string(), value: z12.string() }))
2456
2533
  });
2457
- var UrlsSchema = z11.object({ private: z11.string(), public: z11.string().optional() });
2458
- var ManagedSchema = z11.object({
2459
- kind: z11.string(),
2460
- 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(),
2461
2538
  /** The owning slug, bare. */
2462
- owner: z11.string(),
2463
- ownerKind: z11.enum(["user", "org"]),
2539
+ owner: z12.string(),
2540
+ ownerKind: z12.enum(["user", "org"]),
2464
2541
  /** `running`, `stopped` (storage only is charged), `hibernated` or `standby` (out of credit), `unknown` (its host does not answer). */
2465
2542
  status: BoxStatusSchema,
2466
2543
  /** The catalog version: `18`. */
2467
- version: z11.string(),
2544
+ version: z12.string(),
2468
2545
  /** What the kind keeps of its create options, defaults filled in: `{database, user}` for Postgres, `{}` for a kind with none. */
2469
- settings: z11.record(z11.string(), z11.string()),
2470
- storageGib: z11.number().int(),
2546
+ settings: z12.record(z12.string(), z12.string()),
2547
+ storageGib: z12.number().int(),
2471
2548
  /** Where a linked box reaches it: `<name>.<slug>.kvbox` (resolves from a box of any slug it is linked to) and the port. */
2472
- private: z11.object({ host: z11.string(), port: z11.number().int() }),
2549
+ private: z12.object({ host: z12.string(), port: z12.number().int() }),
2473
2550
  /** Where the internet reaches it, null while it is not public. The port is its own for its whole life. */
2474
- public: z11.object({ host: z11.string(), port: z11.number().int() }).nullable(),
2551
+ public: z12.object({ host: z12.string(), port: z12.number().int() }).nullable(),
2475
2552
  /** The boxes linked to it, as the caller would name them. */
2476
- links: z11.array(z11.string()),
2553
+ links: z12.array(z12.string()),
2477
2554
  /** The name of the host it runs on, for `--near` and links. */
2478
- host: z11.string(),
2479
- country: z11.string().optional(),
2480
- createdBy: z11.string().nullable(),
2481
- createdAt: z11.string(),
2555
+ host: z12.string(),
2556
+ country: z12.string().optional(),
2557
+ createdBy: z12.string().nullable(),
2558
+ createdAt: z12.string(),
2482
2559
  /** Connection strings with the password as `****`. */
2483
2560
  urls: UrlsSchema,
2484
2561
  price: PriceSchema,
@@ -2487,232 +2564,232 @@ var ManagedSchema = z11.object({
2487
2564
  /** Only in `GET /managed/<kind>/<name>` (asked live): null when it is not running or did not answer. */
2488
2565
  health: ManagedHealthSchema.nullable().optional()
2489
2566
  });
2490
- var ManagedSecretSchema = z11.object({ password: z11.string(), urls: UrlsSchema });
2567
+ var ManagedSecretSchema = z12.object({ password: z12.string(), urls: UrlsSchema });
2491
2568
  var CreatedManagedSchema = ManagedSchema.extend({
2492
2569
  secret: ManagedSecretSchema,
2493
2570
  /** The backup it was made from (`fromBackup`), when it was. */
2494
- fromBackup: z11.string().optional()
2495
- });
2496
- var ResetPasswordRequest = z11.object({ password: z11.string().optional() });
2497
- var SetPublicRequest = z11.object({ on: z11.boolean() });
2498
- var ManagedLinkRequest = z11.object({ box: z11.string() });
2499
- var GrowManagedRequest = z11.object({ storageGib: z11.number().int() });
2500
- var ManagedBackupSchema = z11.object({
2501
- id: z11.string(),
2502
- owner: z11.string(),
2503
- kind: z11.string(),
2504
- name: z11.string(),
2505
- version: z11.string(),
2506
- 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),
2507
2584
  /** Why it failed; null otherwise. */
2508
- error: z11.string().nullable(),
2585
+ error: z12.string().nullable(),
2509
2586
  /** The service's storage when taken. */
2510
- diskBytes: z11.number().int().nullable(),
2587
+ diskBytes: z12.number().int().nullable(),
2511
2588
  /** What it holds: the slots that are not all zeros. */
2512
- dataBytes: z11.number().int().nullable(),
2589
+ dataBytes: z12.number().int().nullable(),
2513
2590
  /** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
2514
- uploadedBytes: z11.number().int().nullable(),
2591
+ uploadedBytes: z12.number().int().nullable(),
2515
2592
  /** Who asked for it; for a scheduled one, the database's creator. */
2516
- createdBy: z11.string().nullable(),
2593
+ createdBy: z12.string().nullable(),
2517
2594
  /** Started by the database's backup schedule, not by a person: it does not count toward the daily limit. */
2518
- scheduled: z11.boolean().default(false),
2519
- createdAt: z11.string(),
2520
- finishedAt: z11.string().nullable()
2595
+ scheduled: z12.boolean().default(false),
2596
+ createdAt: z12.string(),
2597
+ finishedAt: z12.string().nullable()
2521
2598
  });
2522
2599
 
2523
2600
  // ../shared/src/cron.ts
2524
- import { z as z12 } from "zod";
2601
+ import { z as z13 } from "zod";
2525
2602
  var DEFAULT_CRON_COMMAND_TIMEOUT_SEC = 600;
2526
2603
  var MAX_CRON_COMMAND_TIMEOUT_SEC = 3600;
2527
2604
  var CRON_RUN_LOG_DIR = "/var/log/kvbox/runs";
2528
2605
  var CRON_METHODS = ["GET", "POST"];
2529
2606
  var CRON_OUTCOMES = ["running", "ok", "failed", "timeout", "no-credit", "box-stopped", "host-down", "host-outdated", "lost", "still-running", "box-outdated"];
2530
- var CronServiceSchema = z12.object({
2531
- owner: z12.string(),
2532
- ownerKind: z12.enum(["user", "org"]),
2533
- name: z12.string(),
2607
+ var CronServiceSchema = z13.object({
2608
+ owner: z13.string(),
2609
+ ownerKind: z13.enum(["user", "org"]),
2610
+ name: z13.string(),
2534
2611
  /** Runs kept per trigger. */
2535
- keepRuns: z12.number().int(),
2536
- triggers: z12.number().int(),
2537
- createdBy: z12.string().nullable(),
2538
- createdAt: z12.string(),
2612
+ keepRuns: z13.number().int(),
2613
+ triggers: z13.number().int(),
2614
+ createdBy: z13.string().nullable(),
2615
+ createdAt: z13.string(),
2539
2616
  /** What it costs while it exists; on the answer to `POST /cron` only. */
2540
- price: z12.object({ perMonth: z12.number(), currency: z12.string() }).optional()
2617
+ price: z13.object({ perMonth: z13.number(), currency: z13.string() }).optional()
2541
2618
  });
2542
2619
  var triggerCommon = {
2543
- id: z12.string(),
2544
- service: z12.string(),
2545
- owner: z12.string(),
2620
+ id: z13.string(),
2621
+ service: z13.string(),
2622
+ owner: z13.string(),
2546
2623
  /** The box it acts on; a trigger is removed with its box. */
2547
- box: z12.string(),
2624
+ box: z13.string(),
2548
2625
  /** Five fields, `minute hour day-of-month month day-of-week`. */
2549
- expr: z12.string(),
2626
+ expr: z13.string(),
2550
2627
  /** An IANA zone (`Europe/Bucharest`) the expression is read in; `UTC` unless said. */
2551
- timezone: z12.string(),
2628
+ timezone: z13.string(),
2552
2629
  /** False: paused, it fires again when resumed. */
2553
- enabled: z12.boolean(),
2630
+ enabled: z13.boolean(),
2554
2631
  /** When it fires next (ISO); null while paused. */
2555
- nextRunAt: z12.string().nullable(),
2556
- lastRunAt: z12.string().nullable(),
2557
- lastOutcome: z12.enum(CRON_OUTCOMES).nullable(),
2558
- createdBy: z12.string().nullable(),
2559
- 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()
2560
2637
  };
2561
- var CronHttpTriggerSchema = z12.object({
2638
+ var CronHttpTriggerSchema = z13.object({
2562
2639
  ...triggerCommon,
2563
- kind: z12.literal("http"),
2564
- method: z12.enum(CRON_METHODS),
2565
- port: z12.number().int(),
2640
+ kind: z13.literal("http"),
2641
+ method: z13.enum(CRON_METHODS),
2642
+ port: z13.number().int(),
2566
2643
  /** Path and query, starting with `/`. */
2567
- path: z12.string()
2644
+ path: z13.string()
2568
2645
  });
2569
- var CronCommandTriggerSchema = z12.object({
2646
+ var CronCommandTriggerSchema = z13.object({
2570
2647
  ...triggerCommon,
2571
- kind: z12.literal("command"),
2648
+ kind: z13.literal("command"),
2572
2649
  /** Run by a login shell as the box's user, in its home. */
2573
- command: z12.string(),
2650
+ command: z13.string(),
2574
2651
  /** The command is stopped after this long. */
2575
- timeoutSec: z12.number().int()
2652
+ timeoutSec: z13.number().int()
2576
2653
  });
2577
- var CronTriggerSchema = z12.discriminatedUnion("kind", [CronHttpTriggerSchema, CronCommandTriggerSchema]);
2578
- var CronRunSchema = z12.object({
2654
+ var CronTriggerSchema = z13.discriminatedUnion("kind", [CronHttpTriggerSchema, CronCommandTriggerSchema]);
2655
+ var CronRunSchema = z13.object({
2579
2656
  /** The slot this run was for (ISO); a run asked for by hand has the moment it was asked. */
2580
- scheduledFor: z12.string(),
2581
- startedAt: z12.string(),
2657
+ scheduledFor: z13.string(),
2658
+ startedAt: z13.string(),
2582
2659
  /** Null while `running`, and for a run that was never sent. */
2583
- durationMs: z12.number().int().nullable(),
2660
+ durationMs: z13.number().int().nullable(),
2584
2661
  /** The box's HTTP status; null when it never answered, and for a command. */
2585
- status: z12.number().int().nullable(),
2662
+ status: z13.number().int().nullable(),
2586
2663
  /** A command's exit code (128 + the signal when one ended it); null until it ends, and for a request. */
2587
- exitCode: z12.number().int().nullable(),
2664
+ exitCode: z13.number().int().nullable(),
2588
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. */
2589
- output: z12.string().nullable(),
2590
- outcome: z12.enum(CRON_OUTCOMES),
2666
+ output: z13.string().nullable(),
2667
+ outcome: z13.enum(CRON_OUTCOMES),
2591
2668
  /** Why it did not end `ok`, in a line. */
2592
- error: z12.string().nullable(),
2669
+ error: z13.string().nullable(),
2593
2670
  /** The box was hibernated and this run woke it. */
2594
- woke: z12.boolean()
2671
+ woke: z13.boolean()
2595
2672
  });
2596
- var CronCatalogSchema = z12.object({
2597
- price: z12.object({ perMonth: z12.number(), currency: z12.string() }),
2598
- maxServices: z12.number().int(),
2599
- maxTriggers: z12.number().int(),
2600
- 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(),
2601
2678
  /** The shortest time between two runs of one trigger, in seconds. */
2602
- minIntervalSeconds: z12.number().int(),
2679
+ minIntervalSeconds: z13.number().int(),
2603
2680
  /** How long a box has to answer, in seconds. */
2604
- timeoutSeconds: z12.number().int(),
2681
+ timeoutSeconds: z13.number().int(),
2605
2682
  /** How long a command may run: unless the trigger says, and at most. */
2606
- commandTimeoutSeconds: z12.number().int(),
2607
- maxCommandTimeoutSeconds: z12.number().int(),
2608
- docs: z12.string().optional()
2609
- });
2610
- var CreateCronServiceRequest = z12.object({ name: z12.string() });
2611
- var CreateCronTriggerRequest = z12.object({
2612
- box: z12.string().min(1),
2613
- expr: z12.string().min(1),
2614
- 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(),
2615
2692
  /** A request: `port`, with `method` and `path`. */
2616
- method: z12.enum(CRON_METHODS).optional(),
2617
- port: z12.number().int().min(1).max(65535).optional(),
2618
- 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(),
2619
2696
  /** Or a command, with `timeoutSec`; exactly one of `port` and `command`. */
2620
- command: z12.string().optional(),
2621
- timeoutSec: z12.number().int().optional()
2697
+ command: z13.string().optional(),
2698
+ timeoutSec: z13.number().int().optional()
2622
2699
  });
2623
- var UpdateCronTriggerRequest = z12.object({ enabled: z12.boolean() });
2700
+ var UpdateCronTriggerRequest = z13.object({ enabled: z13.boolean() });
2624
2701
  var cronTarget = (t) => t.kind === "command" ? `${t.box}$ ${t.command}` : `${t.method} ${t.box}:${t.port}${t.path}`;
2625
2702
 
2626
2703
  // ../shared/src/storage.ts
2627
- import { z as z13 } from "zod";
2628
- 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() });
2629
2706
  var MAX_PUBLIC_BUCKETS = 10;
2630
2707
  var STORAGE_BOX_SUBDOMAINS = MAX_PUBLIC_BUCKETS + 2;
2631
- var ObjectStorageSchema = z13.object({
2632
- owner: z13.string(),
2633
- ownerKind: z13.enum(["user", "org"]),
2708
+ var ObjectStorageSchema = z14.object({
2709
+ owner: z14.string(),
2710
+ ownerKind: z14.enum(["user", "org"]),
2634
2711
  /** `https://s3-<slug>.<domain>`: what an S3 client is given, with path-style addressing. Null while the address is not claimed. */
2635
- endpoint: z13.string().nullable(),
2712
+ endpoint: z14.string().nullable(),
2636
2713
  /** The S3 region every client of it signs with (`ro-west-1`): its host's when it was made. */
2637
- region: z13.string(),
2714
+ region: z14.string(),
2638
2715
  /** The most it may hold. */
2639
- sizeGib: z13.number().int(),
2716
+ sizeGib: z14.number().int(),
2640
2717
  /** `running` when it answers; `unknown` while its host is not heard from. */
2641
2718
  status: BoxStatusSchema,
2642
2719
  /** With `?live=1`, when the storage answered: what is on its disk, and the disk's real size. */
2643
- usedBytes: z13.number().optional(),
2644
- totalBytes: z13.number().optional(),
2720
+ usedBytes: z14.number().optional(),
2721
+ totalBytes: z14.number().optional(),
2645
2722
  /** With `?live=1`, when the storage answered: what each bucket holds. */
2646
- bucketUsage: z13.array(z13.object({ name: z13.string(), objects: z13.number(), bytes: z13.number() })).optional(),
2647
- host: z13.string(),
2648
- country: z13.string().optional(),
2649
- buckets: z13.number().int(),
2650
- price: z13.object({ perMonth: z13.number(), currency: z13.string() }),
2651
- createdAt: z13.string()
2652
- });
2653
- var BucketSchema = z13.object({
2654
- name: z13.string(),
2655
- owner: z13.string(),
2656
- ownerKind: z13.enum(["user", "org"]),
2657
- endpoint: z13.string().nullable(),
2658
- publicUrl: z13.string().optional(),
2659
- region: z13.string(),
2660
- keys: z13.number().int(),
2661
- objects: z13.number().optional(),
2662
- bytes: z13.number().optional(),
2663
- createdBy: z13.string().nullable(),
2664
- createdAt: z13.string()
2665
- });
2666
- var CreateBucketRequest = z13.object({
2667
- name: z13.string(),
2668
- sizeGib: z13.number().int().optional(),
2669
- near: z13.string().optional(),
2670
- region: z13.string().optional()
2671
- });
2672
- 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() });
2673
2750
  var BucketInfoSchema = BucketSchema.extend({ storage: ObjectStorageSchema });
2674
- var SetBucketPublicRequest = z13.object({ on: z13.boolean(), sub: z13.string().optional() });
2675
- var BucketKeySchema = z13.object({
2676
- id: z13.string(),
2677
- name: z13.string(),
2678
- bucket: z13.string(),
2679
- owner: z13.string(),
2680
- readOnly: z13.boolean(),
2681
- createdBy: z13.string().nullable(),
2682
- createdAt: z13.string()
2683
- });
2684
- var CreateBucketKeyRequest = z13.object({ name: z13.string().optional(), readOnly: z13.boolean().optional() });
2685
- var CreatedBucketKeySchema = BucketKeySchema.extend({ secret: z13.string(), endpoint: z13.string().nullable(), region: z13.string() });
2686
- var GrowStorageRequest = z13.object({ sizeGib: z13.number().int() });
2687
- var StorageBackupSchema = z13.object({
2688
- id: z13.string(),
2689
- owner: z13.string(),
2690
- 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),
2691
2768
  /** Why it failed; null otherwise. */
2692
- error: z13.string().nullable(),
2769
+ error: z14.string().nullable(),
2693
2770
  /** The storage's volume when taken. */
2694
- diskBytes: z13.number().int().nullable(),
2771
+ diskBytes: z14.number().int().nullable(),
2695
2772
  /** What it holds: the slots that are not all zeros. */
2696
- dataBytes: z13.number().int().nullable(),
2773
+ dataBytes: z14.number().int().nullable(),
2697
2774
  /** What this backup added to the backup store (encrypted, compressed). */
2698
- uploadedBytes: z13.number().int().nullable(),
2775
+ uploadedBytes: z14.number().int().nullable(),
2699
2776
  /** The buckets it holds, and how many access keys they had, as kvbox knew them when it was taken. */
2700
- buckets: z13.array(z13.string()),
2701
- keys: z13.number().int(),
2702
- createdBy: z13.string().nullable(),
2777
+ buckets: z14.array(z14.string()),
2778
+ keys: z14.number().int(),
2779
+ createdBy: z14.string().nullable(),
2703
2780
  /** Taken by the storage's nightly schedule rather than by a person: free, and outside the daily limit. */
2704
- scheduled: z13.boolean().default(false),
2705
- createdAt: z13.string(),
2706
- finishedAt: z13.string().nullable()
2781
+ scheduled: z14.boolean().default(false),
2782
+ createdAt: z14.string(),
2783
+ finishedAt: z14.string().nullable()
2707
2784
  });
2708
- var RestoredKeySchema = z13.object({ bucket: z13.string(), id: z13.string(), name: z13.string() });
2709
- var StorageRestoreSchema = z13.object({
2710
- 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(),
2711
2788
  storage: ObjectStorageSchema,
2712
- buckets: z13.object({ kept: z13.array(z13.string()), returned: z13.array(z13.string()), removed: z13.array(z13.string()) }),
2713
- keys: z13.object({ dropped: z13.array(RestoredKeySchema), revoked: z13.array(RestoredKeySchema) }),
2714
- checked: z13.boolean(),
2715
- 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())
2716
2793
  });
2717
2794
  var OBJECT_LIST_MAX = 1e3;
2718
2795
  var SHARE_LINK_MAX_SEC = 7 * 24 * 3600;
@@ -2722,56 +2799,56 @@ var MULTIPART_PART_BYTES = 16 * 1024 * 1024;
2722
2799
  var UPLOAD_MAX_BYTES = 50 * 1024 * 1024 * 1024;
2723
2800
  var MOVE_MAX_BYTES = 5 * 1024 * 1024 * 1024;
2724
2801
  var DELETE_PREFIXES_MAX = 100;
2725
- var StoredObjectSchema = z13.object({
2726
- key: z13.string(),
2727
- size: z13.number(),
2728
- etag: z13.string(),
2802
+ var StoredObjectSchema = z14.object({
2803
+ key: z14.string(),
2804
+ size: z14.number(),
2805
+ etag: z14.string(),
2729
2806
  /** ISO 8601. */
2730
- modified: z13.string()
2731
- });
2732
- var ObjectListingSchema = z13.object({
2733
- prefix: z13.string(),
2734
- folders: z13.array(z13.string()),
2735
- objects: z13.array(StoredObjectSchema),
2736
- next: z13.string().optional(),
2737
- canWrite: z13.boolean()
2738
- });
2739
- var ObjectInfoSchema = StoredObjectSchema.extend({ contentType: z13.string() });
2740
- var ObjectCountSchema = z13.object({ objects: z13.number(), bytes: z13.number(), more: z13.boolean() });
2741
- var ObjectLinkRequest = z13.object({
2742
- key: z13.string(),
2743
- 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(),
2744
2821
  /** Answer as a download (`Content-Disposition: attachment`) instead of showing it. */
2745
- download: z13.boolean().optional(),
2822
+ download: z14.boolean().optional(),
2746
2823
  /**
2747
2824
  * Let the browser keep what the link answers until the link expires (`Cache-Control: private`, `Expires`),
2748
2825
  * so the same link shown twice is fetched once. Asked again within the hour, for the same file as it
2749
2826
  * is, it is the same URL, and it lasts up to an hour longer than `expiresSec`. For the app's own previews.
2750
2827
  * Only a fetch of the whole file is kept so: the storage answers a part of one (`Range`) without the two headers.
2751
2828
  */
2752
- cached: z13.boolean().optional()
2829
+ cached: z14.boolean().optional()
2753
2830
  });
2754
- var ObjectLinkSchema = z13.object({ url: z13.string(), expiresAt: z13.string() });
2831
+ var ObjectLinkSchema = z14.object({ url: z14.string(), expiresAt: z14.string() });
2755
2832
  var MEDIA_TYPE_RE = /^[\w.+-]+\/[\w.+-]+(?:\s*;[\x20-\x7e]*)?$/;
2756
- 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() });
2757
- var UploadPlanSchema = z13.discriminatedUnion("kind", [
2758
- z13.object({ kind: z13.literal("single"), url: z13.string() }),
2759
- 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()) })
2760
2837
  ]);
2761
- var CompleteUploadRequest = z13.object({
2762
- key: z13.string(),
2763
- uploadId: z13.string(),
2764
- 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)
2765
2842
  });
2766
- var AbortUploadRequest = z13.object({ key: z13.string(), uploadId: z13.string() });
2767
- var DeleteObjectsRequest = z13.object({ keys: z13.array(z13.string()).max(OBJECT_LIST_MAX).optional(), prefixes: z13.array(z13.string()).max(DELETE_PREFIXES_MAX).optional() });
2768
- var DeletedObjectsSchema = z13.object({
2769
- deleted: z13.number(),
2770
- more: z13.boolean(),
2771
- 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() }))
2772
2849
  });
2773
- var MoveObjectRequest = z13.object({ from: z13.string(), to: z13.string(), overwrite: z13.boolean().optional() });
2774
- 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() });
2775
2852
 
2776
2853
  // src/kvm.ts
2777
2854
  import { accessSync, constants, readFileSync, statSync } from "fs";
@@ -2941,7 +3018,7 @@ var ServerClient = class {
2941
3018
  * `all`: every box on the platform (platform admins only, #78).
2942
3019
  */
2943
3020
  listMachines(opts = {}) {
2944
- 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);
2945
3022
  }
2946
3023
  createMachine(req) {
2947
3024
  return this.call("POST", "/machines", MachineSchema, req, void 0, req.fromBackup !== void 0 ? 2 * 36e5 : void 0);
@@ -2995,10 +3072,10 @@ var ServerClient = class {
2995
3072
  }
2996
3073
  /** Backups, the control plane's only: a box's disk in object storage. Newest first. */
2997
3074
  listBackups() {
2998
- return this.call("GET", "/backups", z14.array(BackupSchema));
3075
+ return this.call("GET", "/backups", z15.array(BackupSchema));
2999
3076
  }
3000
3077
  boxBackups(name) {
3001
- return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z14.array(BackupSchema));
3078
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z15.array(BackupSchema));
3002
3079
  }
3003
3080
  boxBackup(name, id) {
3004
3081
  return this.call("GET", `/machines/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, BackupSchema);
@@ -3020,14 +3097,14 @@ var ServerClient = class {
3020
3097
  * later. Works for a backup whose box, volume or database is gone too.
3021
3098
  */
3022
3099
  removeBackup(id) {
3023
- return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z14.undefined());
3100
+ return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z15.undefined());
3024
3101
  }
3025
3102
  /** A volume's backups (#168): the same as a box's, of the volume's disk. Newest first. */
3026
3103
  listVolumeBackups() {
3027
- return this.call("GET", "/backups?kind=volume", z14.array(VolumeBackupSchema));
3104
+ return this.call("GET", "/backups?kind=volume", z15.array(VolumeBackupSchema));
3028
3105
  }
3029
3106
  volumeBackups(name) {
3030
- return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z14.array(VolumeBackupSchema));
3107
+ return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z15.array(VolumeBackupSchema));
3031
3108
  }
3032
3109
  volumeBackup(name, id) {
3033
3110
  return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, VolumeBackupSchema);
@@ -3053,7 +3130,7 @@ var ServerClient = class {
3053
3130
  }
3054
3131
  /** Wake hooks (#101), the control plane's only: a URL and a secret that wake the box. */
3055
3132
  boxHooks(name) {
3056
- return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z14.array(WakeHookSchema));
3133
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z15.array(WakeHookSchema));
3057
3134
  }
3058
3135
  createBoxHook(name) {
3059
3136
  return this.call("POST", `/machines/${encodeURIComponent(name)}/hooks`, CreatedWakeHookSchema);
@@ -3081,7 +3158,7 @@ var ServerClient = class {
3081
3158
  }
3082
3159
  /** Every readable box's subdomains, one entry each. */
3083
3160
  listSubdomains() {
3084
- return this.call("GET", "/subdomains", z14.array(SubdomainSchema));
3161
+ return this.call("GET", "/subdomains", z15.array(SubdomainSchema));
3085
3162
  }
3086
3163
  /** Custom domains (#89), the control plane's only: serve the box at the user's own name. */
3087
3164
  addDomain(name, req) {
@@ -3092,7 +3169,7 @@ var ServerClient = class {
3092
3169
  }
3093
3170
  /** Every readable box's custom domains. */
3094
3171
  listDomains() {
3095
- return this.call("GET", "/domains", z14.array(DomainSchema));
3172
+ return this.call("GET", "/domains", z15.array(DomainSchema));
3096
3173
  }
3097
3174
  /** A running box's own load, memory and disk, asked of its guest (#67). */
3098
3175
  machineStats(name) {
@@ -3107,6 +3184,10 @@ var ServerClient = class {
3107
3184
  machineTraffic(name, query) {
3108
3185
  return this.call("GET", `/machines/${encodeURIComponent(name)}/traffic${query}`, TrafficReportSchema);
3109
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
+ }
3110
3191
  /** Every box of the caller over the window (#41 on a host, #42 through a control plane); dates as the user wrote them. */
3111
3192
  usageReport(since, until2, all = false) {
3112
3193
  const q = new URLSearchParams();
@@ -3129,22 +3210,22 @@ var ServerClient = class {
3129
3210
  return this.call("POST", "/billing/redeem", RedeemResponseSchema, { code });
3130
3211
  }
3131
3212
  deleteMachine(name) {
3132
- return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z14.undefined());
3213
+ return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z15.undefined());
3133
3214
  }
3134
3215
  /** Like `listMachines`, for snapshots. */
3135
3216
  listSnapshots(opts = {}) {
3136
- 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);
3137
3218
  }
3138
3219
  createSnapshot(req) {
3139
3220
  return this.call("POST", "/snapshots", SnapshotSchema, req);
3140
3221
  }
3141
3222
  deleteSnapshot(name) {
3142
- return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z14.undefined());
3223
+ return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z15.undefined());
3143
3224
  }
3144
3225
  // ---- environment variables (#88), a control plane only: the caller's slug, or `--org`'s ----
3145
3226
  /** `org`: that org's list instead of `--org`'s (or the caller's own). */
3146
3227
  listEnv(org) {
3147
- return this.call("GET", "/vars", z14.array(EnvVarSchema), void 0, org);
3228
+ return this.call("GET", "/vars", z15.array(EnvVarSchema), void 0, org);
3148
3229
  }
3149
3230
  setEnv(name, req) {
3150
3231
  return this.call("PUT", `/vars/${encodeURIComponent(name)}`, EnvChangeSchema, req);
@@ -3164,13 +3245,13 @@ var ServerClient = class {
3164
3245
  }
3165
3246
  // ---- volumes (#52) ----
3166
3247
  listVolumes(opts = {}) {
3167
- 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);
3168
3249
  }
3169
3250
  createVolume(req) {
3170
3251
  return this.call("POST", "/volumes", VolumeSchema, req);
3171
3252
  }
3172
3253
  deleteVolume(name) {
3173
- return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z14.undefined());
3254
+ return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z15.undefined());
3174
3255
  }
3175
3256
  /** Both answer with the box as it is afterwards (restarted when it was running). */
3176
3257
  attachVolume(name, req) {
@@ -3185,7 +3266,7 @@ var ServerClient = class {
3185
3266
  }
3186
3267
  // ---- cron service (#190): the control plane's alone ----
3187
3268
  listCronServices(opts = {}) {
3188
- 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);
3189
3270
  }
3190
3271
  createCronService(name) {
3191
3272
  return this.call("POST", "/cron", CronServiceSchema, { name });
@@ -3194,10 +3275,10 @@ var ServerClient = class {
3194
3275
  return this.call("GET", `/cron/${encodeURIComponent(name)}`, CronServiceSchema);
3195
3276
  }
3196
3277
  deleteCronService(name) {
3197
- return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z14.undefined());
3278
+ return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z15.undefined());
3198
3279
  }
3199
3280
  listCronTriggers(service) {
3200
- return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z14.array(CronTriggerSchema));
3281
+ return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z15.array(CronTriggerSchema));
3201
3282
  }
3202
3283
  addCronTrigger(service, req) {
3203
3284
  return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers`, CronTriggerSchema, req);
@@ -3207,18 +3288,18 @@ var ServerClient = class {
3207
3288
  return this.call("PATCH", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, CronTriggerSchema, { enabled: enabled2 });
3208
3289
  }
3209
3290
  deleteCronTrigger(service, id) {
3210
- 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());
3211
3292
  }
3212
3293
  /** Marks it due: kvbox-cron fires it within a few seconds. */
3213
3294
  runCronTrigger(service, id) {
3214
3295
  return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/run`, CronTriggerSchema);
3215
3296
  }
3216
3297
  listCronRuns(service, id, limit) {
3217
- 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));
3218
3299
  }
3219
3300
  // ---- object storage (#182): the control plane's alone ----
3220
3301
  listBuckets(opts = {}) {
3221
- 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);
3222
3303
  }
3223
3304
  /** The first bucket of a slug also makes its storage: a box boots twice, so this may take a couple of minutes. */
3224
3305
  createBucket(req) {
@@ -3232,26 +3313,26 @@ var ServerClient = class {
3232
3313
  return this.call("PUT", `/buckets/${encodeURIComponent(name)}/public`, BucketSchema, req);
3233
3314
  }
3234
3315
  deleteBucket(name, force = false) {
3235
- 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());
3236
3317
  }
3237
3318
  listBucketKeys(name) {
3238
- return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z14.array(BucketKeySchema));
3319
+ return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z15.array(BucketKeySchema));
3239
3320
  }
3240
3321
  createBucketKey(name, req) {
3241
3322
  return this.call("POST", `/buckets/${encodeURIComponent(name)}/keys`, CreatedBucketKeySchema, req);
3242
3323
  }
3243
3324
  deleteBucketKey(name, id) {
3244
- 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());
3245
3326
  }
3246
3327
  listStorage(opts = {}) {
3247
- 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);
3248
3329
  }
3249
3330
  growStorage(sizeGib) {
3250
3331
  return this.call("POST", "/storage/grow", ObjectStorageSchema, { sizeGib });
3251
3332
  }
3252
3333
  /** Backups of the slug's whole object storage (#186 slice 3), newest first. */
3253
3334
  storageBackups() {
3254
- return this.call("GET", "/storage/backups", z14.array(StorageBackupSchema));
3335
+ return this.call("GET", "/storage/backups", z15.array(StorageBackupSchema));
3255
3336
  }
3256
3337
  storageBackup(id) {
3257
3338
  return this.call("GET", `/storage/backups/${encodeURIComponent(id)}`, StorageBackupSchema);
@@ -3279,11 +3360,11 @@ var ServerClient = class {
3279
3360
  return `/managed/${encodeURIComponent(kind)}${name === void 0 ? "" : `/${encodeURIComponent(name)}`}${rest}`;
3280
3361
  }
3281
3362
  managedCatalog() {
3282
- return this.call("GET", "/managed/catalog", z14.array(ManagedCatalogEntrySchema));
3363
+ return this.call("GET", "/managed/catalog", z15.array(ManagedCatalogEntrySchema));
3283
3364
  }
3284
3365
  /** One kind's services, or every kind's when `kind` is left out. */
3285
3366
  listManaged(kind, opts = {}) {
3286
- 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);
3287
3368
  }
3288
3369
  /** From a backup (`fromBackup`) it waits for the restore too: the control plane gives its host 2 h for the download. */
3289
3370
  createManaged(kind, req) {
@@ -3294,7 +3375,7 @@ var ServerClient = class {
3294
3375
  return this.call("GET", this.managedPath(kind, name), ManagedSchema);
3295
3376
  }
3296
3377
  deleteManaged(kind, name) {
3297
- return this.call("DELETE", this.managedPath(kind, name), z14.undefined());
3378
+ return this.call("DELETE", this.managedPath(kind, name), z15.undefined());
3298
3379
  }
3299
3380
  managedPassword(kind, name) {
3300
3381
  return this.call("GET", this.managedPath(kind, name, "/password"), ManagedSecretSchema);
@@ -3316,10 +3397,10 @@ var ServerClient = class {
3316
3397
  }
3317
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. */
3318
3399
  listManagedBackups(kind) {
3319
- return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z14.array(ManagedBackupSchema));
3400
+ return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z15.array(ManagedBackupSchema));
3320
3401
  }
3321
3402
  managedBackups(kind, name) {
3322
- 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));
3323
3404
  }
3324
3405
  managedBackup(kind, name, id) {
3325
3406
  return this.call("GET", this.managedPath(kind, name, `/backups/${encodeURIComponent(id)}`), ManagedBackupSchema);
@@ -3361,7 +3442,7 @@ var ServerClient = class {
3361
3442
  return this.call("POST", "/login/device/token", DeviceLoginPollSchema, { deviceCode });
3362
3443
  }
3363
3444
  logout() {
3364
- return this.call("POST", "/logout", z14.unknown()).then(() => void 0);
3445
+ return this.call("POST", "/logout", z15.unknown()).then(() => void 0);
3365
3446
  }
3366
3447
  me() {
3367
3448
  return this.call("GET", "/me", MeResponseSchema);
@@ -3372,25 +3453,25 @@ var ServerClient = class {
3372
3453
  * credential. Null: each readable slug whatever `--org` says, which is how the caller's own slug is read.
3373
3454
  */
3374
3455
  listIntegrations(org) {
3375
- return this.call("GET", "/integrations", z14.array(IntegrationSchema), void 0, org);
3456
+ return this.call("GET", "/integrations", z15.array(IntegrationSchema), void 0, org);
3376
3457
  }
3377
3458
  /** What can be connected on this control plane, and by which kind of slug. */
3378
3459
  integrationCatalog() {
3379
- 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);
3380
3461
  }
3381
3462
  // ---- API keys (`kvbox key …`, #189) ----
3382
3463
  listApiKeys() {
3383
- return this.call("GET", "/keys", z14.array(ApiKeySchema));
3464
+ return this.call("GET", "/keys", z15.array(ApiKeySchema));
3384
3465
  }
3385
3466
  createApiKey(req) {
3386
3467
  return this.call("POST", "/keys", CreatedApiKeySchema, req);
3387
3468
  }
3388
3469
  deleteApiKey(name) {
3389
- 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);
3390
3471
  }
3391
3472
  // ---- orgs (`kvbox org …`) ----
3392
3473
  listOrgs() {
3393
- return this.call("GET", "/orgs", z14.array(OrgMembershipSchema));
3474
+ return this.call("GET", "/orgs", z15.array(OrgMembershipSchema));
3394
3475
  }
3395
3476
  createOrg(req) {
3396
3477
  return this.call("POST", "/orgs", CloudOrgSchema, req);
@@ -3399,16 +3480,16 @@ var ServerClient = class {
3399
3480
  return this.call("GET", `/orgs/${encodeURIComponent(slug)}`, OrgDetailSchema);
3400
3481
  }
3401
3482
  deleteOrg(slug) {
3402
- return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z14.undefined());
3483
+ return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z15.undefined());
3403
3484
  }
3404
3485
  addMember(slug, req) {
3405
- return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z14.undefined(), req);
3486
+ return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z15.undefined(), req);
3406
3487
  }
3407
3488
  setRole(slug, username, role) {
3408
- 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);
3409
3490
  }
3410
3491
  removeMember(slug, username) {
3411
- 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());
3412
3493
  }
3413
3494
  /** Sign this machine's key again (#51); the key must be one the user logged in with. */
3414
3495
  sshCert(req) {
@@ -3490,10 +3571,10 @@ function sshArgs(ep, p = paths()) {
3490
3571
  ];
3491
3572
  }
3492
3573
  async function waitForSsh(ep, timeoutMs = 3e4) {
3493
- const { connect } = await import("net");
3574
+ const { connect: connect2 } = await import("net");
3494
3575
  const deadline = Date.now() + timeoutMs;
3495
3576
  const attempt = () => new Promise((resolve4) => {
3496
- const sock = connect({ host: ep.host, port: ep.port, timeout: 1e3 });
3577
+ const sock = connect2({ host: ep.host, port: ep.port, timeout: 1e3 });
3497
3578
  sock.once("connect", () => {
3498
3579
  sock.destroy();
3499
3580
  resolve4(true);
@@ -3518,8 +3599,8 @@ async function checkDirect(ep) {
3518
3599
  var NOT_LOGGED_IN = "you are not logged in. Run: kvbox login";
3519
3600
  var NOT_A_HOST_HINT = "kvbox-server is not installed, so this machine is not a kvbox host. Set it up with install-server.sh, or log in to the cloud with: kvbox login";
3520
3601
  async function lastErrorLine(logPath, from = 0) {
3521
- const { readFile: readFile8 } = await import("fs/promises");
3522
- const text2 = (await readFile8(logPath).catch(() => Buffer.alloc(0))).subarray(from).toString("utf8");
3602
+ const { readFile: readFile10 } = await import("fs/promises");
3603
+ const text2 = (await readFile10(logPath).catch(() => Buffer.alloc(0))).subarray(from).toString("utf8");
3523
3604
  for (const line of text2.trimEnd().split("\n").slice(-20).reverse()) {
3524
3605
  const m = /^(?:\[[^\]]*\])?\[?error\]?: (.*)$/.exec(line);
3525
3606
  if (m?.[1] !== void 0) return m[1];
@@ -3530,11 +3611,11 @@ async function startLocalServer(p = paths(), timeoutMs = 5e3) {
3530
3611
  await mkdir3(p.home, { recursive: true });
3531
3612
  if (hasUnitFor(p)) return startUnit(p, timeoutMs);
3532
3613
  const log = openSync(p.serverLog, "a");
3533
- const launcher = serverLauncher();
3534
- const child = spawn(launcher.cmd, launcher.args, { detached: true, stdio: ["ignore", log, log] });
3614
+ const launcher2 = serverLauncher();
3615
+ const child = spawn(launcher2.cmd, launcher2.args, { detached: true, stdio: ["ignore", log, log] });
3535
3616
  const failed = new Promise((_, reject) => {
3536
3617
  child.once("error", (err) => {
3537
- reject(new KvboxError(err.code === "ENOENT" && launcher.viaGroup === void 0 ? NOT_A_HOST_HINT : `could not start kvbox-server: ${err.message}`));
3618
+ reject(new KvboxError(err.code === "ENOENT" && launcher2.viaGroup === void 0 ? NOT_A_HOST_HINT : `could not start kvbox-server: ${err.message}`));
3538
3619
  });
3539
3620
  child.once("exit", (code) => {
3540
3621
  void lastErrorLine(p.serverLog).then((why) => {
@@ -3546,7 +3627,7 @@ async function startLocalServer(p = paths(), timeoutMs = 5e3) {
3546
3627
  child.removeAllListeners("exit");
3547
3628
  child.unref();
3548
3629
  const pid = Number.parseInt(await readFile3(p.serverPid, "utf8").catch(() => ""), 10);
3549
- return { pid: Number.isNaN(pid) ? child.pid ?? -1 : pid, socketPath: p.serverSock, viaGroup: launcher.viaGroup };
3630
+ return { pid: Number.isNaN(pid) ? child.pid ?? -1 : pid, socketPath: p.serverSock, viaGroup: launcher2.viaGroup };
3550
3631
  }
3551
3632
  async function startUnit(p, timeoutMs) {
3552
3633
  const logFrom = await stat(p.serverLog).then((s) => s.size, () => 0);
@@ -5086,6 +5167,12 @@ function printSchedule(what, command, schedule, flags, changed) {
5086
5167
  info(color.dim(` last turn ${schedule.lastAt.slice(0, 16).replace("T", " ")} UTC: `) + last);
5087
5168
  }
5088
5169
  }
5170
+ async function printNightlyCost(client, schedule, flags) {
5171
+ if (flags.json || !schedule.enabled) return;
5172
+ const prices = await client.priceList().catch(() => void 0);
5173
+ if (!prices || prices.scheduledBackup <= 0) return;
5174
+ info(color.dim(` costs ${money(prices.scheduledBackup, prices.currency)} a night once the backup is ready, nothing if it fails`));
5175
+ }
5089
5176
 
5090
5177
  // src/commands/vm/backup/schedule.ts
5091
5178
  var scheduleCommand = scheduleFlags(new Command29("schedule").description("show or switch a box's nightly backup (daily, UTC; off until you turn it on)").argument("<box>", "box name")).action(
@@ -5098,6 +5185,7 @@ var scheduleCommand = scheduleFlags(new Command29("schedule").description("show
5098
5185
  const changed = Object.keys(change).length > 0;
5099
5186
  const schedule = changed ? await client.setBoxBackupSchedule(box2, change) : await client.boxBackupSchedule(box2);
5100
5187
  printSchedule(`box ${box2}`, `kvbox vm backup schedule ${box2}`, schedule, flags, changed);
5188
+ await printNightlyCost(client, schedule, flags);
5101
5189
  } finally {
5102
5190
  await client.close();
5103
5191
  }
@@ -5145,19 +5233,123 @@ function parseCount(text2) {
5145
5233
  return n2;
5146
5234
  }
5147
5235
  function parseSize(flag, text2) {
5148
- const mib = parseMib(text2);
5149
- if (mib === void 0) throw new KvboxError(`${flag} ${text2}: give a size like 16GB or 4096MB`);
5150
- 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;
5151
5239
  }
5152
5240
  function parseGib(flag, text2) {
5153
- const mib = parseSize(flag, text2);
5154
- if (mib % 1024 !== 0) throw new KvboxError(`${flag} ${text2}: disk sizes are whole GB`);
5155
- 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;
5156
5244
  }
5157
5245
 
5158
- // 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
5159
5250
  import { Command as Command32 } from "commander";
5160
- 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) => {
5161
5353
  const client = await clientFor(cmd.optsWithGlobals());
5162
5354
  try {
5163
5355
  const box2 = await spin(`resuming ${name}\u2026`, client.resumeMachine(name));
@@ -5169,8 +5361,8 @@ var resumeCommand = new Command32("resume").description("continue a box that is
5169
5361
  });
5170
5362
 
5171
5363
  // src/commands/vm/rm.ts
5172
- import { Command as Command33 } from "commander";
5173
- 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) => {
5174
5366
  const client = await clientFor(cmd.optsWithGlobals());
5175
5367
  try {
5176
5368
  const box2 = pickRef(await boxesFor(client, name), name, me(client));
@@ -5190,7 +5382,7 @@ var rmCommand4 = new Command33("rm").description("destroy a box (its disk is del
5190
5382
  });
5191
5383
 
5192
5384
  // src/commands/vm/set.ts
5193
- import { Command as Command34 } from "commander";
5385
+ import { Command as Command36 } from "commander";
5194
5386
 
5195
5387
  // src/swap.ts
5196
5388
  import { spawn as spawn4 } from "child_process";
@@ -5200,9 +5392,9 @@ var SWAP_MIN_MIB = 256;
5200
5392
  function parseSwap(text2) {
5201
5393
  const t = text2.trim().toLowerCase();
5202
5394
  if (t === "off" || t === "none" || t === "0") return 0;
5203
- const mib = parseMib(t);
5204
- 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`);
5205
- 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;
5206
5398
  }
5207
5399
  function swapScript() {
5208
5400
  return [
@@ -5246,16 +5438,16 @@ function swapScript() {
5246
5438
  'echo "kvbox-swap ${3:-0} ${4:-0} $(cat "$zs" 2>/dev/null || echo N)"'
5247
5439
  ].join("\n");
5248
5440
  }
5249
- function swapCommand(mib) {
5250
- 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}`;
5251
5443
  }
5252
5444
  function parseSwapReport(output) {
5253
5445
  const m = /^kvbox-swap (\d+) (\d+) (\S+)\s*$/m.exec(output);
5254
5446
  if (!m) return void 0;
5255
5447
  return { sizeMib: Math.round(Number(m[1]) / 1024), usedMib: Math.round(Number(m[2]) / 1024), zswap: m[3] === "Y" || m[3] === "1" };
5256
5448
  }
5257
- function runSwap(ep, mib) {
5258
- 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"] });
5259
5451
  const chunks = [];
5260
5452
  child.stdout.on("data", (c2) => chunks.push(c2));
5261
5453
  child.stderr.on("data", (c2) => chunks.push(c2));
@@ -5266,7 +5458,7 @@ function runSwap(ep, mib) {
5266
5458
  }
5267
5459
 
5268
5460
  // src/commands/vm/set.ts
5269
- 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) => {
5270
5462
  if (opts.autoHibernate === void 0 && opts.idleCheck === void 0 && opts.integration === void 0 && opts.swap === void 0) {
5271
5463
  throw new KvboxError("nothing to change: give --auto-hibernate, --idle-check, --integration or --swap");
5272
5464
  }
@@ -5307,17 +5499,17 @@ var setCommand = new Command34("set").description("change a box's settings, e.g.
5307
5499
  await client.close();
5308
5500
  }
5309
5501
  });
5310
- async function setSwap(client, found, name, mib, cmd) {
5502
+ async function setSwap(client, found, name, mib2, cmd) {
5311
5503
  const cert = await ensureCert(client, void 0, void 0, { owner: found.owner });
5312
5504
  const wasRunning = found.status === "running";
5313
5505
  const box2 = wasRunning ? found : await wakeUp(client, found, displayName(found, me(client)));
5314
5506
  const ep = sshEndpoint(box2, client.target);
5315
5507
  if (!wasRunning) await spin(`waiting for ${name} to accept SSH\u2026`, waitForSsh(ep));
5316
- const what = mib === 0 ? `removing ${name}'s swap\u2026` : `setting up ${mib >= 1024 ? `${mib / 1024}G` : `${mib}M`} of swap in ${name}\u2026`;
5317
- 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));
5318
5510
  if (result.status === 255) {
5319
5511
  const again = await clientFor(cmd.optsWithGlobals());
5320
- 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));
5321
5513
  }
5322
5514
  const report = parseSwapReport(result.output);
5323
5515
  if (result.status !== 0 || !report) {
@@ -5344,8 +5536,8 @@ function parseIdleCheck(text2) {
5344
5536
  }
5345
5537
 
5346
5538
  // src/commands/vm/start.ts
5347
- import { Command as Command35 } from "commander";
5348
- 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) => {
5349
5541
  const client = await clientFor(cmd.optsWithGlobals());
5350
5542
  try {
5351
5543
  const box2 = await spin(`booting ${name}\u2026`, client.startMachine(name, opts.force ?? false));
@@ -5357,8 +5549,8 @@ var startCommand = new Command35("start").description("boot a stopped box again
5357
5549
  });
5358
5550
 
5359
5551
  // src/commands/vm/stop.ts
5360
- import { Command as Command36 } from "commander";
5361
- 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) => {
5362
5554
  const client = await clientFor(cmd.optsWithGlobals());
5363
5555
  try {
5364
5556
  const box2 = await spin(`shutting ${name} down\u2026`, client.stopMachine(name));
@@ -5370,8 +5562,8 @@ var stopCommand = new Command36("stop").description("shut a box down (its disk i
5370
5562
  });
5371
5563
 
5372
5564
  // src/commands/vm/top.ts
5373
- import { Command as Command37 } from "commander";
5374
- 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) => {
5375
5567
  const client = await clientFor(cmd.optsWithGlobals());
5376
5568
  try {
5377
5569
  const running = (await client.listMachines({ all: opts.all })).filter((b) => b.status === "running");
@@ -5414,7 +5606,7 @@ async function mapLimit(items, limit, fn) {
5414
5606
  await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
5415
5607
  return out;
5416
5608
  }
5417
- 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)}%`) : "";
5418
5610
  function topRows(entries, cloud) {
5419
5611
  return entries.map((e) => {
5420
5612
  const s = e.stats;
@@ -5422,80 +5614,17 @@ function topRows(entries, cloud) {
5422
5614
  ...cloud ? { owner: ownerCell(e, cloud.me) } : {},
5423
5615
  name: boxName(e.name),
5424
5616
  load: s ? `${s.load[0].toFixed(2)} ${s.load[1].toFixed(2)} ${color.dim(`/${s.cpus}`)}` : "-",
5425
- mem: s ? `${gbShort(s.memUsedMib * 1024 ** 2)}/${gbShort(s.memTotalMib * 1024 ** 2)}${pct(s.memUsedMib, s.memTotalMib)}` : "-",
5426
- 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)}` : "-",
5427
5619
  // duration() writes "-" for 0, which here would read as "no numbers".
5428
5620
  uptime: s ? s.uptimeSec >= 1 ? duration(s.uptimeSec) : "0s" : "-"
5429
5621
  };
5430
5622
  });
5431
5623
  }
5432
5624
 
5433
- // src/commands/vm/traffic.ts
5434
- import { Command as Command38 } from "commander";
5435
- 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) => {
5436
- const q = new URLSearchParams();
5437
- if (opts.since !== void 0) q.set("since", sinceOf(opts.since));
5438
- if (opts.host !== void 0) q.set("host", opts.host);
5439
- const client = await clientFor(cmd.optsWithGlobals());
5440
- try {
5441
- if (client.target.kind !== "cloud") throw new KvboxError("traffic is counted by the kvbox cloud's edge: kvbox login first");
5442
- const report = await client.machineTraffic(name, q.size === 0 ? "" : `?${q.toString()}`);
5443
- if (opts.json) json(report);
5444
- else if (report.totals.requests === 0) info(`no requests reached ${name} through its HTTPS names since ${when(report.since)}`);
5445
- else process.stdout.write(block2(report));
5446
- } finally {
5447
- await client.close();
5448
- }
5449
- });
5450
- var UNITS = { m: 6e4, h: 36e5, d: 864e5 };
5451
- function sinceOf(text2, now = Date.now()) {
5452
- const span = /^(\d+)([mhd])$/.exec(text2.trim());
5453
- if (span) return new Date(now - Number(span[1]) * UNITS[span[2]]).toISOString();
5454
- const t = Date.parse(text2);
5455
- if (Number.isNaN(t)) throw new KvboxError(`--since ${text2}: write a span like 1h, 24h or 7d, or a date like 2026-11-19`);
5456
- return new Date(t).toISOString();
5457
- }
5458
- var when = (iso2) => `${iso2.slice(0, 16).replace("T", " ")} UTC`;
5459
- var n = (v) => v.toLocaleString("en-US");
5460
- function bytes(v) {
5461
- if (v < 1e3) return `${v} B`;
5462
- const units = ["kB", "MB", "GB", "TB"];
5463
- let x = v;
5464
- let u = -1;
5465
- while (x >= 1e3 && u < units.length - 1) {
5466
- x /= 1e3;
5467
- u++;
5468
- }
5469
- return `${x < 10 ? x.toFixed(1) : Math.round(x)} ${units[u]}`;
5470
- }
5471
- var ms = (v) => v === null ? "-" : v >= 1e3 ? `${v / 1e3} s` : `${v} ms`;
5472
- var share = (part, whole) => whole === 0 || part === 0 ? "" : color.dim(` (${(part / whole * 100).toFixed(part === whole ? 0 : 1)}%)`);
5473
- function block2(r) {
5474
- const t = r.totals;
5475
- const rows2 = [
5476
- ["name", boxName(r.box)],
5477
- ["window", `${when(r.since)} to ${when(r.until)}`],
5478
- ["hosts", r.host ?? (r.hosts.join(", ") || "-")],
5479
- ["requests", n(t.requests)],
5480
- ["2xx", n(t.s2xx) + share(t.s2xx, t.requests)],
5481
- ["3xx", n(t.s3xx) + share(t.s3xx, t.requests)],
5482
- ["4xx", n(t.s4xx) + share(t.s4xx, t.requests)],
5483
- ["5xx", (t.s5xx > 0 ? color.red(n(t.s5xx)) : "0") + share(t.s5xx, t.requests)],
5484
- ["latency", `p50 \u2264 ${ms(t.p50Ms)}, p95 \u2264 ${ms(t.p95Ms)}`],
5485
- ["bytes in", bytes(t.bytesIn)],
5486
- ["bytes out", bytes(t.bytesOut)],
5487
- ["wakes", t.wakes === 0 ? "0" : `${n(t.wakes)}, waited ${ms(t.wakeWaitMs)} on average`]
5488
- ];
5489
- const width2 = Math.max(...rows2.map(([k]) => k.length));
5490
- const lines = rows2.map(([k, v]) => `${color.dim(k.padStart(width2))} ${v}`);
5491
- lines.push(color.dim("published ports and SSH do not pass the edge and are not counted"));
5492
- return `${lines.join("\n")}
5493
- `;
5494
- }
5495
-
5496
5625
  // src/commands/vm/unlink.ts
5497
- import { Command as Command39 } from "commander";
5498
- 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) => {
5499
5628
  const port = parseLinkPort(opts.port);
5500
5629
  if (!await confirm(`Cut box ${from} off from box ${name} port ${port}? Its open connections close too.`, opts.yes ?? false)) {
5501
5630
  info("cancelled");
@@ -5516,8 +5645,8 @@ var unlinkCommand = new Command39("unlink").description("take a link away (kvbox
5516
5645
  });
5517
5646
 
5518
5647
  // src/commands/vm/update.ts
5519
- import { Command as Command40 } from "commander";
5520
- 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) => {
5521
5650
  const client = await clientFor(cmd.optsWithGlobals());
5522
5651
  try {
5523
5652
  const before = pickRef(await boxesFor(client, name), name, me(client));
@@ -5539,8 +5668,8 @@ var updateCommand = new Command40("update").description("move a box onto the cur
5539
5668
  });
5540
5669
 
5541
5670
  // src/commands/vm/wake.ts
5542
- import { Command as Command41 } from "commander";
5543
- 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) => {
5544
5673
  const client = await clientFor(cmd.optsWithGlobals());
5545
5674
  try {
5546
5675
  const box2 = await spin(`waking ${name} (loading its memory from disk)\u2026`, client.wakeMachine(name, opts.force ?? false));
@@ -5552,7 +5681,7 @@ var wakeCommand = new Command41("wake").description("continue a hibernated box w
5552
5681
  });
5553
5682
 
5554
5683
  // src/commands/vm/index.ts
5555
- 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);
5556
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)");
5557
5686
  var vmAliases = [newCommand, lsCommand, getCommand, connectCommand, execCommand, cpCommand, stopCommand, startCommand, pauseCommand, resumeCommand, hibernateCommand, wakeCommand, rmCommand4, claimCommand];
5558
5687
 
@@ -5561,7 +5690,7 @@ import { hostname as osHostname2 } from "os";
5561
5690
  import { createInterface as createInterface2 } from "readline/promises";
5562
5691
  import { setTimeout as sleep4 } from "timers/promises";
5563
5692
  import { Writable } from "stream";
5564
- import { Command as Command43 } from "commander";
5693
+ import { Command as Command44 } from "commander";
5565
5694
 
5566
5695
  // src/browser.ts
5567
5696
  import { spawn as spawn5 } from "child_process";
@@ -5598,7 +5727,7 @@ function openBrowser(url) {
5598
5727
  }
5599
5728
 
5600
5729
  // src/commands/login.ts
5601
- 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) => {
5602
5731
  const url = normalizeUrl(urlArg ?? DEFAULT_CLOUD_URL);
5603
5732
  const byPassword = opts.password === true || opts.passwordStdin === true || opts.email !== void 0;
5604
5733
  const session = byPassword ? await runLogin(url, await readCredentials(opts), paths()) : await runDeviceLogin(url, paths());
@@ -5708,8 +5837,8 @@ async function firstLine(stream) {
5708
5837
  }
5709
5838
 
5710
5839
  // src/commands/logout.ts
5711
- import { Command as Command44 } from "commander";
5712
- 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 () => {
5713
5842
  const p = paths();
5714
5843
  const session = await readSession(p).catch(() => null);
5715
5844
  switch (await runLogout(p)) {
@@ -5747,8 +5876,8 @@ async function runLogout(p = paths()) {
5747
5876
  }
5748
5877
 
5749
5878
  // src/commands/whoami.ts
5750
- import { Command as Command45 } from "commander";
5751
- 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) => {
5752
5881
  if (!cmd.optsWithGlobals().local && envLogin()) {
5753
5882
  const target = await resolveTarget({});
5754
5883
  if (target.kind !== "cloud") return;
@@ -5773,10 +5902,10 @@ function describeSession(session) {
5773
5902
  }
5774
5903
 
5775
5904
  // src/commands/key/index.ts
5776
- import { Command as Command49 } from "commander";
5905
+ import { Command as Command50 } from "commander";
5777
5906
 
5778
5907
  // src/commands/key/create.ts
5779
- import { Command as Command46 } from "commander";
5908
+ import { Command as Command47 } from "commander";
5780
5909
 
5781
5910
  // src/commands/key/shared.ts
5782
5911
  async function keyClient(cmd) {
@@ -5813,7 +5942,7 @@ function expiryText(expiresAt, now = Date.now()) {
5813
5942
  }
5814
5943
 
5815
5944
  // src/commands/key/create.ts
5816
- 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) => {
5817
5946
  const expiresAt = opts.expires === void 0 ? void 0 : parseExpires(opts.expires);
5818
5947
  const client = await keyClient(cmd);
5819
5948
  try {
@@ -5831,8 +5960,8 @@ var createCommand3 = new Command46("create").description("make an API key for a
5831
5960
  });
5832
5961
 
5833
5962
  // src/commands/key/ls.ts
5834
- import { Command as Command47 } from "commander";
5835
- 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) => {
5836
5965
  const client = await keyClient(cmd);
5837
5966
  try {
5838
5967
  const keys = await client.listApiKeys();
@@ -5851,8 +5980,8 @@ var lsCommand5 = new Command47("ls").alias("list").description("list your API ke
5851
5980
  });
5852
5981
 
5853
5982
  // src/commands/key/rm.ts
5854
- import { Command as Command48 } from "commander";
5855
- 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) => {
5856
5985
  const client = await keyClient(cmd);
5857
5986
  try {
5858
5987
  if (!await confirm(`Remove API key ${name}? Whatever uses it stops working.`, opts.yes ?? false)) {
@@ -5868,14 +5997,14 @@ var rmCommand5 = new Command48("rm").alias("remove").description("remove an API
5868
5997
  });
5869
5998
 
5870
5999
  // src/commands/key/index.ts
5871
- 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);
5872
6001
 
5873
6002
  // src/commands/integration/index.ts
5874
- import { Command as Command51 } from "commander";
6003
+ import { Command as Command52 } from "commander";
5875
6004
 
5876
6005
  // src/commands/integration/ls.ts
5877
- import { Command as Command50 } from "commander";
5878
- 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) => {
5879
6008
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
5880
6009
  try {
5881
6010
  if (client.target.kind !== "cloud") throw new KvboxError("integrations belong to an account on the kvbox cloud: kvbox login first");
@@ -5904,14 +6033,14 @@ var lsCommand6 = new Command50("ls").alias("list").description("list the account
5904
6033
  });
5905
6034
 
5906
6035
  // src/commands/integration/index.ts
5907
- 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);
5908
6037
 
5909
6038
  // src/commands/snapshots/index.ts
5910
- import { Command as Command55 } from "commander";
6039
+ import { Command as Command56 } from "commander";
5911
6040
 
5912
6041
  // src/commands/snapshots/ls.ts
5913
- import { Command as Command52 } from "commander";
5914
- 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) => {
5915
6044
  const client = await clientFor(cmd.optsWithGlobals());
5916
6045
  try {
5917
6046
  const cloud = client.target.kind === "cloud";
@@ -5942,8 +6071,8 @@ var lsCommand7 = new Command52("ls").description("list snapshots (yours and your
5942
6071
  });
5943
6072
 
5944
6073
  // src/commands/snapshots/new.ts
5945
- import { Command as Command53 } from "commander";
5946
- 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) => {
5947
6076
  const client = await clientFor(cmd.optsWithGlobals());
5948
6077
  try {
5949
6078
  const req = { box: box2, name, ...opts.replace ? { replace: true } : {} };
@@ -5956,8 +6085,8 @@ var newCommand2 = new Command53("new").description("freeze a running box (memory
5956
6085
  });
5957
6086
 
5958
6087
  // src/commands/snapshots/rm.ts
5959
- import { Command as Command54 } from "commander";
5960
- 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) => {
5961
6090
  if (!await confirm(`Delete snapshot ${name}?`, opts.yes ?? false)) {
5962
6091
  info("cancelled");
5963
6092
  process.exitCode = 1;
@@ -5973,14 +6102,14 @@ var rmCommand6 = new Command54("rm").description("delete a snapshot (boxes made
5973
6102
  });
5974
6103
 
5975
6104
  // src/commands/snapshots/index.ts
5976
- 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);
5977
6106
  for (const cmd of snapshotsCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
5978
6107
 
5979
6108
  // src/commands/org/index.ts
5980
- import { Command as Command61 } from "commander";
6109
+ import { Command as Command62 } from "commander";
5981
6110
 
5982
6111
  // src/commands/org/ls.ts
5983
- import { Command as Command56 } from "commander";
6112
+ import { Command as Command57 } from "commander";
5984
6113
 
5985
6114
  // src/commands/org/context.ts
5986
6115
  var NOT_LOGGED_IN2 = "orgs live on the control plane: kvbox login first";
@@ -6000,7 +6129,7 @@ function orgFor(opts, target) {
6000
6129
  }
6001
6130
 
6002
6131
  // src/commands/org/ls.ts
6003
- 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) => {
6004
6133
  const client = await cloudClientFor(cmd.optsWithGlobals());
6005
6134
  try {
6006
6135
  const orgs = await client.listOrgs();
@@ -6022,8 +6151,8 @@ function orgRows(orgs) {
6022
6151
  }
6023
6152
 
6024
6153
  // src/commands/org/members.ts
6025
- import { Command as Command57, Option as Option4 } from "commander";
6026
- 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) => {
6027
6156
  const client = await cloudClientFor(cmd.optsWithGlobals());
6028
6157
  try {
6029
6158
  const org = await client.getOrg(orgFor(opts, client.target));
@@ -6037,7 +6166,7 @@ var lsCommand9 = new Command57("ls").description("list an org's members and thei
6037
6166
  await client.close();
6038
6167
  }
6039
6168
  });
6040
- 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) => {
6041
6170
  const client = await cloudClientFor(cmd.optsWithGlobals());
6042
6171
  try {
6043
6172
  const slug = orgFor(opts, client.target);
@@ -6047,7 +6176,7 @@ var addCommand2 = new Command57("add").description("add a user to an org (admins
6047
6176
  await client.close();
6048
6177
  }
6049
6178
  });
6050
- 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) => {
6051
6180
  const client = await cloudClientFor(cmd.optsWithGlobals());
6052
6181
  try {
6053
6182
  const slug = orgFor(opts, client.target);
@@ -6063,11 +6192,11 @@ var rmCommand7 = new Command57("rm").description("remove a member (or leave: rem
6063
6192
  await client.close();
6064
6193
  }
6065
6194
  });
6066
- 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);
6067
6196
 
6068
6197
  // src/commands/org/new.ts
6069
- import { Command as Command58 } from "commander";
6070
- 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) => {
6071
6200
  const client = await cloudClientFor(cmd.optsWithGlobals());
6072
6201
  try {
6073
6202
  const org = await client.createOrg({ slug, name: opts.name ?? slug });
@@ -6083,8 +6212,8 @@ var newCommand3 = new Command58("new").description("create an org; you become it
6083
6212
  });
6084
6213
 
6085
6214
  // src/commands/org/rm.ts
6086
- import { Command as Command59 } from "commander";
6087
- 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) => {
6088
6217
  if (!await confirm(`Delete org ${slug}? Its members lose access; its slug stays taken.`, opts.yes ?? false)) {
6089
6218
  info("cancelled");
6090
6219
  process.exitCode = 1;
@@ -6100,8 +6229,8 @@ var rmCommand8 = new Command59("rm").description("delete an org (owners only; re
6100
6229
  });
6101
6230
 
6102
6231
  // src/commands/org/role.ts
6103
- import { Argument, Command as Command60 } from "commander";
6104
- 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) => {
6105
6234
  const client = await cloudClientFor(cmd.optsWithGlobals());
6106
6235
  try {
6107
6236
  const slug = orgFor(opts, client.target);
@@ -6113,11 +6242,11 @@ var roleCommand = new Command60("role").description("change a member's role (own
6113
6242
  });
6114
6243
 
6115
6244
  // src/commands/org/index.ts
6116
- 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);
6117
6246
 
6118
6247
  // src/commands/usage.ts
6119
- import { Command as Command62 } from "commander";
6120
- 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) => {
6121
6250
  for (const [name, value] of [
6122
6251
  ["since", opts.since],
6123
6252
  ["until", opts.until]
@@ -6156,7 +6285,7 @@ var usageCommand2 = new Command62("usage").description("what your boxes and volu
6156
6285
  }
6157
6286
  if (backups.length > 0) {
6158
6287
  const taken = backups.reduce((n2, b) => n2 + b.count, 0);
6159
- info(taken === 1 ? "1 backup taken by hand" : `${taken} backups taken by hand`);
6288
+ info(taken === 1 ? "1 paid backup" : `${taken} paid backups`);
6160
6289
  table(backupRows(report, cloud));
6161
6290
  }
6162
6291
  if ((volumes.length > 0 || storage.length > 0 || cron.length > 0 || backups.length > 0) && report.totals.cost !== void 0) {
@@ -6314,8 +6443,8 @@ function userRows(r) {
6314
6443
  }
6315
6444
 
6316
6445
  // src/commands/credit.ts
6317
- import { Command as Command63 } from "commander";
6318
- 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) => {
6319
6448
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
6320
6449
  try {
6321
6450
  if (client.target.kind === "local") throw new KvboxError("credit lives on the control plane: kvbox login first");
@@ -6344,8 +6473,8 @@ function creditRow(b, me2) {
6344
6473
  }
6345
6474
 
6346
6475
  // src/commands/redeem.ts
6347
- import { Command as Command64 } from "commander";
6348
- 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) => {
6349
6478
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
6350
6479
  try {
6351
6480
  if (client.target.kind === "local") throw new KvboxError("codes are redeemed on the control plane: kvbox login first");
@@ -6365,12 +6494,12 @@ var redeemCommand = new Command64("redeem").description("redeem a promo code for
6365
6494
  // src/commands/deploy/index.ts
6366
6495
  import { access as access5, readFile as readFile7 } from "fs/promises";
6367
6496
  import { basename as basename2, resolve as resolve3 } from "path";
6368
- 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";
6369
6498
 
6370
6499
  // src/commands/deploy/config.ts
6371
6500
  import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
6372
6501
  import { isAbsolute, join as join6, normalize, relative as relative2 } from "path";
6373
- import { z as z15 } from "zod";
6502
+ import { z as z16 } from "zod";
6374
6503
 
6375
6504
  // src/commands/deploy/templates/docker.ts
6376
6505
  import { readFile as readFile4 } from "fs/promises";
@@ -6794,21 +6923,21 @@ function detectTemplates(pkg, dir = NO_FACTS) {
6794
6923
  var DEPLOY_AUTO_HIBERNATE_SEC = 3600;
6795
6924
  var CONFIG_FILE = "kvbox.json";
6796
6925
  var BOX_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
6797
- var DeployConfigSchema = z15.object({
6798
- template: z15.enum(TEMPLATE_IDS),
6799
- 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"),
6800
6929
  /** The org whose box it is; absent for the user's own. */
6801
- 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(),
6802
6931
  /** The HTTPS name (`<subdomain>.kvbox.app`); absent when deploying to this machine's own host. */
6803
- subdomain: z15.string().check((ctx) => {
6932
+ subdomain: z16.string().check((ctx) => {
6804
6933
  const problem = subdomainProblem(ctx.value);
6805
6934
  if (problem) ctx.issues.push({ code: "custom", message: problem, input: ctx.value });
6806
6935
  }).optional(),
6807
- size: z15.enum(SIZE_NAMES).optional(),
6936
+ size: z16.enum(SIZE_NAMES).optional(),
6808
6937
  /** The build output directory, relative to the app; the template's default when absent. */
6809
- dist: z15.string().optional(),
6938
+ dist: z16.string().optional(),
6810
6939
  /** The port a Next.js app or Node server serves; the template's (3000) when absent. */
6811
- port: z15.number().int().min(1).max(65535).optional()
6940
+ port: z16.number().int().min(1).max(65535).optional()
6812
6941
  });
6813
6942
  var SERVICE_KEY_RE = /^[a-z][a-z0-9-]{0,19}$/;
6814
6943
  var RESERVED_SERVICE_KEYS = ["app", "agent", "init", "volumes"];
@@ -6820,43 +6949,43 @@ var POSTGRES_PORT = 5432;
6820
6949
  var POSTGRES_IMAGE = "postgres:17";
6821
6950
  var POSTGRES_ENV = "DATABASE_URL";
6822
6951
  var IMAGE_RE = /^[a-z0-9][a-z0-9._/:@-]*$/;
6823
- var ServiceSchema = z15.strictObject({
6824
- template: z15.enum([...TEMPLATE_IDS, POSTGRES]),
6952
+ var ServiceSchema = z16.strictObject({
6953
+ template: z16.enum([...TEMPLATE_IDS, POSTGRES]),
6825
6954
  /** The service's directory, relative to the one holding kvbox.json; every template but postgres has one. */
6826
- dir: z15.string().min(1).optional(),
6955
+ dir: z16.string().min(1).optional(),
6827
6956
  /** A postgres service's image, `postgres:17` when absent (`pgvector/pgvector:pg17` for vectors). */
6828
- 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(),
6829
6958
  /** The volume (a key of `volumes`) a postgres service keeps its data on. */
6830
- volume: z15.string().optional(),
6959
+ volume: z16.string().optional(),
6831
6960
  /** The box variable a postgres service's URL is written to, `DATABASE_URL` when absent. */
6832
- env: z15.string().optional(),
6961
+ env: z16.string().optional(),
6833
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`. */
6834
- context: z15.string().min(1).optional(),
6835
- dist: z15.string().optional(),
6963
+ context: z16.string().min(1).optional(),
6964
+ dist: z16.string().optional(),
6836
6965
  /**
6837
6966
  * A command run once per deploy in the service's new version (a docker service: in a container of
6838
6967
  * the new image; node, nextjs: in the new source, installed and built), with the box's variables,
6839
6968
  * before it replaces the running one. Migrations, mostly. A failing one stops that service's deploy.
6840
6969
  */
6841
- release: z15.string().optional(),
6970
+ release: z16.string().optional(),
6842
6971
  /** The box port of a service with its own server; the template's (3000) when absent. */
6843
- port: z15.number().int().min(1).max(65535).optional(),
6972
+ port: z16.number().int().min(1).max(65535).optional(),
6844
6973
  /** The URL paths that go to this service, each with everything under it; the prefix is kept. */
6845
- 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()
6846
6975
  });
6847
- var StackConfigSchema = z15.strictObject({
6976
+ var StackConfigSchema = z16.strictObject({
6848
6977
  name: DeployConfigSchema.shape.name.optional(),
6849
6978
  org: DeployConfigSchema.shape.org,
6850
6979
  subdomain: DeployConfigSchema.shape.subdomain,
6851
6980
  size: DeployConfigSchema.shape.size,
6852
6981
  /** The stack's volumes, name to size ("10GB"): made for its box and attached to it on the first deploy that needs one. */
6853
- volumes: z15.record(z15.string(), z15.string()).optional(),
6854
- services: z15.record(z15.string(), ServiceSchema)
6982
+ volumes: z16.record(z16.string(), z16.string()).optional(),
6983
+ services: z16.record(z16.string(), ServiceSchema)
6855
6984
  });
6856
6985
  function volumeGib(text2) {
6857
- const mib = parseMib(text2);
6858
- if (mib === void 0 || mib === 0 || mib % 1024 !== 0 || mib / 1024 > MAX_VOLUME_GIB) return void 0;
6859
- 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;
6860
6989
  }
6861
6990
  function stackServices(stack, defaultPort, exposed = /* @__PURE__ */ new Map()) {
6862
6991
  const services = [];
@@ -7229,16 +7358,16 @@ var PROXY = (port) => [
7229
7358
  "proxy_buffering off;",
7230
7359
  "proxy_read_timeout 3600s;"
7231
7360
  ];
7232
- var block3 = (head, body) => [` ${head} {`, ...body.map((l) => ` ${l}`), " }", ""];
7361
+ var block4 = (head, body) => [` ${head} {`, ...body.map((l) => ` ${l}`), " }", ""];
7233
7362
  function locations(service, path) {
7234
7363
  const dist = `/srv/app/${service.key}/dist`;
7235
7364
  if (service.static) {
7236
- if (path === "/") return block3("location /", [`root ${dist};`, "try_files $uri $uri/ /index.html;"]);
7237
- 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;`])];
7238
7367
  }
7239
7368
  const proxy = PROXY(service.port);
7240
- if (path === "/") return block3("location /", proxy);
7241
- 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)];
7242
7371
  }
7243
7372
  function stackSite(services) {
7244
7373
  const routed = services.flatMap((s) => s.paths.map((path) => ({ service: s, path })));
@@ -7266,7 +7395,7 @@ function stackSite(services) {
7266
7395
  "",
7267
7396
  ...routed.flatMap((r) => locations(r.service, r.path)),
7268
7397
  // No service at the top: say so instead of nginx's own welcome page.
7269
- ...root ? [] : block3("location /", ["return 404;"]),
7398
+ ...root ? [] : block4("location /", ["return 404;"]),
7270
7399
  "}",
7271
7400
  ""
7272
7401
  ].join("\n");
@@ -7630,7 +7759,7 @@ async function readPackageJson(dir) {
7630
7759
  }
7631
7760
 
7632
7761
  // src/commands/deploy/index.ts
7633
- 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) => {
7634
7763
  const dir = resolve3(dirArg ?? ".");
7635
7764
  const pkg = await readPackageJson2(dir);
7636
7765
  const facts = { indexHtml: await exists2(resolve3(dir, "index.html")), dockerfile: await exists2(resolve3(dir, "Dockerfile")) };
@@ -7787,15 +7916,15 @@ async function settle2(dir, pkg, facts, saved, opts, orgFlag, cloud) {
7787
7916
  }
7788
7917
 
7789
7918
  // src/commands/volume/index.ts
7790
- import { Command as Command78 } from "commander";
7919
+ import { Command as Command79 } from "commander";
7791
7920
 
7792
7921
  // src/commands/volume/attach.ts
7793
- import { Command as Command66 } from "commander";
7922
+ import { Command as Command67 } from "commander";
7794
7923
  function describeMount(machine, volume2, box2) {
7795
7924
  const path = machine.volumes?.find((v) => volume2 === v.name || volume2.endsWith(`/${v.name}`))?.mountPath ?? volumeMountPath(volume2.slice(volume2.lastIndexOf("/") + 1));
7796
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`;
7797
7926
  }
7798
- 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) => {
7799
7928
  if (volumeArg === void 0 || boxArg === void 0) askOrUsage("give the volume and the box: kvbox volume attach <volume> <box>");
7800
7929
  const client = await clientFor(cmd.optsWithGlobals());
7801
7930
  try {
@@ -7814,11 +7943,11 @@ var attachCommand = new Command66("attach").description("attach a volume to a bo
7814
7943
  });
7815
7944
 
7816
7945
  // src/commands/volume/backup/index.ts
7817
- import { Command as Command72 } from "commander";
7946
+ import { Command as Command73 } from "commander";
7818
7947
 
7819
7948
  // src/commands/volume/backup/create.ts
7820
- import { Command as Command67 } from "commander";
7821
- 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) => {
7822
7951
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7823
7952
  try {
7824
7953
  requireCloud3(client);
@@ -7845,8 +7974,8 @@ var createCommand4 = new Command67("create").description("back up a volume's dis
7845
7974
  });
7846
7975
 
7847
7976
  // src/commands/volume/backup/ls.ts
7848
- import { Command as Command68 } from "commander";
7849
- 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) => {
7850
7979
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7851
7980
  try {
7852
7981
  requireCloud3(client);
@@ -7879,8 +8008,8 @@ var lsCommand10 = new Command68("ls").alias("list").description("list volume bac
7879
8008
  });
7880
8009
 
7881
8010
  // src/commands/volume/backup/restore.ts
7882
- import { Command as Command69 } from "commander";
7883
- 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) => {
7884
8013
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7885
8014
  try {
7886
8015
  requireCloud3(client);
@@ -7903,8 +8032,8 @@ var restoreCommand2 = new Command69("restore").description("put a backup back: t
7903
8032
  });
7904
8033
 
7905
8034
  // src/commands/volume/backup/rm.ts
7906
- import { Command as Command70 } from "commander";
7907
- 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) => {
7908
8037
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7909
8038
  try {
7910
8039
  requireCloud3(client);
@@ -7915,9 +8044,9 @@ var rmCommand9 = new Command70("rm").alias("remove").description("remove a backu
7915
8044
  });
7916
8045
 
7917
8046
  // src/commands/volume/backup/schedule.ts
7918
- import { Command as Command71 } from "commander";
8047
+ import { Command as Command72 } from "commander";
7919
8048
  var scheduleCommand2 = scheduleFlags(
7920
- 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")
7921
8050
  ).action(async (volume2, flags, cmd) => {
7922
8051
  const change = changeOf(flags);
7923
8052
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
@@ -7926,21 +8055,22 @@ var scheduleCommand2 = scheduleFlags(
7926
8055
  const changed = Object.keys(change).length > 0;
7927
8056
  const schedule = changed ? await client.setVolumeBackupSchedule(volume2, change) : await client.volumeBackupSchedule(volume2);
7928
8057
  printSchedule(`volume ${volume2}`, withOrg(client, `kvbox volume backup schedule ${volume2}`), schedule, flags, changed);
8058
+ await printNightlyCost(client, schedule, flags);
7929
8059
  } finally {
7930
8060
  await client.close();
7931
8061
  }
7932
8062
  });
7933
8063
 
7934
8064
  // src/commands/volume/backup/index.ts
7935
- 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);
7936
8066
  for (const cmd of backupCommand2.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
7937
8067
 
7938
8068
  // src/commands/volume/create.ts
7939
- import { Command as Command73 } from "commander";
8069
+ import { Command as Command74 } from "commander";
7940
8070
  function parseGib2(text2, label = "--size") {
7941
- const mib = parseMib(text2);
7942
- if (mib === void 0 || mib % 1024 !== 0) throw new KvboxError(`${label} ${text2}: write whole GB, like 50 or 50GB`);
7943
- 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;
7944
8074
  if (gib > MAX_VOLUME_GIB) throw new KvboxError(`${label} ${text2}: a volume is at most ${MAX_VOLUME_GIB} GB`);
7945
8075
  return gib;
7946
8076
  }
@@ -7952,7 +8082,7 @@ function sizeProblem(answer) {
7952
8082
  return err instanceof KvboxError ? err.message.replace(/^--size \S+: /, "") : String(err);
7953
8083
  }
7954
8084
  }
7955
- 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) => {
7956
8086
  const ask = interactive();
7957
8087
  if (nameArg === void 0 || opts.size === void 0) askOrUsage("give the name and the size: kvbox volume create <name> --size <gb> --box <box>");
7958
8088
  const name = nameArg ?? await text("Volume name", { validate: (a) => VOLUME_NAME_RE.test(a) ? void 0 : VOLUME_NAME_RULE });
@@ -7985,8 +8115,8 @@ var createCommand5 = new Command73("create").alias("new").description("create a
7985
8115
  });
7986
8116
 
7987
8117
  // src/commands/volume/detach.ts
7988
- import { Command as Command74 } from "commander";
7989
- 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) => {
7990
8120
  if (volumeArg === void 0) askOrUsage("give the volume: kvbox volume detach <volume> [box]");
7991
8121
  const client = await clientFor(cmd.optsWithGlobals());
7992
8122
  try {
@@ -8011,8 +8141,8 @@ var detachCommand = new Command74("detach").description("detach a volume from a
8011
8141
  });
8012
8142
 
8013
8143
  // src/commands/volume/grow.ts
8014
- import { Command as Command75 } from "commander";
8015
- 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) => {
8016
8146
  const sizeGib = parseGib2(size, "size");
8017
8147
  const client = await clientFor(cmd.optsWithGlobals());
8018
8148
  try {
@@ -8025,8 +8155,8 @@ var growCommand = new Command75("grow").alias("resize").description("make a volu
8025
8155
  });
8026
8156
 
8027
8157
  // src/commands/volume/ls.ts
8028
- import { Command as Command76 } from "commander";
8029
- 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) => {
8030
8160
  const client = await clientFor(cmd.optsWithGlobals());
8031
8161
  try {
8032
8162
  const cloud = client.target.kind === "cloud";
@@ -8057,8 +8187,8 @@ var lsCommand11 = new Command76("ls").alias("list").description("list volumes: s
8057
8187
  });
8058
8188
 
8059
8189
  // src/commands/volume/rm.ts
8060
- import { Command as Command77 } from "commander";
8061
- 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) => {
8062
8192
  if (!await confirm(`Delete volume ${name} and everything on it?`, opts.yes ?? false)) {
8063
8193
  info("cancelled");
8064
8194
  process.exitCode = 1;
@@ -8074,18 +8204,18 @@ var rmCommand10 = new Command77("rm").alias("remove").description("delete a volu
8074
8204
  });
8075
8205
 
8076
8206
  // src/commands/volume/index.ts
8077
- 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);
8078
8208
  for (const cmd of volumeCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
8079
8209
  volumeCommand.addCommand(backupCommand2);
8080
8210
 
8081
8211
  // src/commands/bucket/index.ts
8082
- import { Command as Command95 } from "commander";
8212
+ import { Command as Command96 } from "commander";
8083
8213
 
8084
8214
  // src/commands/bucket/backup/index.ts
8085
- import { Command as Command84 } from "commander";
8215
+ import { Command as Command85 } from "commander";
8086
8216
 
8087
8217
  // src/commands/bucket/backup/create.ts
8088
- import { Command as Command79 } from "commander";
8218
+ import { Command as Command80 } from "commander";
8089
8219
 
8090
8220
  // src/commands/bucket/shared.ts
8091
8221
  async function bucketClient(cmd) {
@@ -8111,7 +8241,7 @@ function printRows(rows2) {
8111
8241
  }
8112
8242
 
8113
8243
  // src/commands/bucket/backup/create.ts
8114
- 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) => {
8115
8245
  const client = await bucketClient(cmd);
8116
8246
  const ls = "kvbox bucket backup ls";
8117
8247
  try {
@@ -8139,8 +8269,8 @@ var createCommand6 = new Command79("create").description("back up your object st
8139
8269
  });
8140
8270
 
8141
8271
  // src/commands/bucket/backup/ls.ts
8142
- import { Command as Command80 } from "commander";
8143
- 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) => {
8144
8274
  const client = await bucketClient(cmd);
8145
8275
  try {
8146
8276
  const list = await client.storageBackups();
@@ -8172,8 +8302,8 @@ var lsCommand12 = new Command80("ls").alias("list").description("list the backup
8172
8302
  });
8173
8303
 
8174
8304
  // src/commands/bucket/backup/restore.ts
8175
- import { Command as Command81 } from "commander";
8176
- 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) => {
8177
8307
  const client = await bucketClient(cmd);
8178
8308
  try {
8179
8309
  const backup = await client.storageBackup(id);
@@ -8203,8 +8333,8 @@ var restoreCommand3 = new Command81("restore").description("put a backup back: e
8203
8333
  });
8204
8334
 
8205
8335
  // src/commands/bucket/backup/rm.ts
8206
- import { Command as Command82 } from "commander";
8207
- 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) => {
8208
8338
  const client = await bucketClient(cmd);
8209
8339
  try {
8210
8340
  const backup = (await client.storageBackups()).find((b) => b.id === id);
@@ -8223,8 +8353,8 @@ var rmCommand11 = new Command82("rm").alias("remove").description("remove a back
8223
8353
  });
8224
8354
 
8225
8355
  // src/commands/bucket/backup/schedule.ts
8226
- import { Command as Command83 } from "commander";
8227
- 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(
8228
8358
  async (flags, cmd) => {
8229
8359
  const change = changeOf(flags);
8230
8360
  const client = await bucketClient(cmd);
@@ -8232,6 +8362,7 @@ var scheduleCommand3 = scheduleFlags(new Command83("schedule").description("show
8232
8362
  const changed = Object.keys(change).length > 0;
8233
8363
  const schedule = changed ? await client.setStorageBackupSchedule(change) : await client.storageBackupSchedule();
8234
8364
  printSchedule("object storage", withOrg(client, "kvbox bucket backup schedule"), schedule, flags, changed);
8365
+ await printNightlyCost(client, schedule, flags);
8235
8366
  } finally {
8236
8367
  await client.close();
8237
8368
  }
@@ -8239,11 +8370,11 @@ var scheduleCommand3 = scheduleFlags(new Command83("schedule").description("show
8239
8370
  );
8240
8371
 
8241
8372
  // src/commands/bucket/backup/index.ts
8242
- 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);
8243
8374
 
8244
8375
  // src/commands/bucket/create.ts
8245
- import { Command as Command85 } from "commander";
8246
- 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) => {
8247
8378
  const sizeGib = opts.size === void 0 ? void 0 : parseGib2(opts.size);
8248
8379
  const client = await bucketClient(cmd);
8249
8380
  try {
@@ -8263,8 +8394,8 @@ var createCommand7 = new Command85("create").description("make a bucket (the fir
8263
8394
  });
8264
8395
 
8265
8396
  // src/commands/bucket/grow.ts
8266
- import { Command as Command86 } from "commander";
8267
- 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) => {
8268
8399
  const sizeGib = parseGib2(size, "size");
8269
8400
  const client = await bucketClient(cmd);
8270
8401
  try {
@@ -8277,8 +8408,8 @@ var growCommand2 = new Command86("grow").description("make your object storage l
8277
8408
  });
8278
8409
 
8279
8410
  // src/commands/bucket/info.ts
8280
- import { Command as Command87 } from "commander";
8281
- 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) => {
8282
8413
  const client = await bucketClient(cmd);
8283
8414
  try {
8284
8415
  const b = await client.getBucket(name);
@@ -8308,11 +8439,11 @@ with the AWS CLI: aws s3 ls s3://${b.name} --endpoint-url ${b.endpoint}`));
8308
8439
  });
8309
8440
 
8310
8441
  // src/commands/bucket/key/index.ts
8311
- import { Command as Command91 } from "commander";
8442
+ import { Command as Command92 } from "commander";
8312
8443
 
8313
8444
  // src/commands/bucket/key/create.ts
8314
- import { Command as Command88 } from "commander";
8315
- 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) => {
8316
8447
  const client = await bucketClient(cmd);
8317
8448
  try {
8318
8449
  const key = await client.createBucketKey(bucket, { ...opts.name !== void 0 ? { name: opts.name } : {}, ...opts.readOnly ? { readOnly: true } : {} });
@@ -8335,8 +8466,8 @@ var createCommand8 = new Command88("create").description("make an access key for
8335
8466
  });
8336
8467
 
8337
8468
  // src/commands/bucket/key/ls.ts
8338
- import { Command as Command89 } from "commander";
8339
- 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) => {
8340
8471
  const client = await bucketClient(cmd);
8341
8472
  try {
8342
8473
  const keys = await client.listBucketKeys(bucket);
@@ -8355,8 +8486,8 @@ var lsCommand13 = new Command89("ls").alias("list").description("list a bucket's
8355
8486
  });
8356
8487
 
8357
8488
  // src/commands/bucket/key/rm.ts
8358
- import { Command as Command90 } from "commander";
8359
- 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) => {
8360
8491
  const client = await bucketClient(cmd);
8361
8492
  try {
8362
8493
  if (!await confirm(`Delete key ${id} of bucket ${bucket}? Whatever uses it stops working.`, opts.yes ?? false)) {
@@ -8372,11 +8503,11 @@ var rmCommand12 = new Command90("rm").alias("remove").description("delete an acc
8372
8503
  });
8373
8504
 
8374
8505
  // src/commands/bucket/key/index.ts
8375
- 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);
8376
8507
 
8377
8508
  // src/commands/bucket/ls.ts
8378
- import { Command as Command92 } from "commander";
8379
- 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) => {
8380
8511
  const client = await bucketClient(cmd);
8381
8512
  try {
8382
8513
  const buckets = await client.listBuckets({ all: opts.all });
@@ -8407,8 +8538,8 @@ var lsCommand14 = new Command92("ls").alias("list").description("list buckets, a
8407
8538
  });
8408
8539
 
8409
8540
  // src/commands/bucket/public.ts
8410
- import { Command as Command93 } from "commander";
8411
- 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) => {
8412
8543
  if (state !== "on" && state !== "off") throw new KvboxError(`"${state}": say on or off`);
8413
8544
  const on = state === "on";
8414
8545
  if (!on && opts.sub !== void 0) throw new KvboxError("--sub goes with on");
@@ -8436,8 +8567,8 @@ var publicCommand = new Command93("public").description("let anyone read a bucke
8436
8567
  });
8437
8568
 
8438
8569
  // src/commands/bucket/rm.ts
8439
- import { Command as Command94 } from "commander";
8440
- 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) => {
8441
8572
  const client = await bucketClient(cmd);
8442
8573
  try {
8443
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?`;
@@ -8456,7 +8587,7 @@ var rmCommand13 = new Command94("rm").alias("remove").description("delete an emp
8456
8587
  });
8457
8588
 
8458
8589
  // src/commands/bucket/index.ts
8459
- 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);
8460
8591
  var withOrg2 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal buckets)");
8461
8592
  for (const cmd of bucketCommand.commands) {
8462
8593
  if (cmd === keyCommand2 || cmd === backupCommand3) cmd.commands.forEach(withOrg2);
@@ -8464,10 +8595,10 @@ for (const cmd of bucketCommand.commands) {
8464
8595
  }
8465
8596
 
8466
8597
  // src/commands/cron/index.ts
8467
- import { Command as Command108 } from "commander";
8598
+ import { Command as Command109 } from "commander";
8468
8599
 
8469
8600
  // src/commands/cron/create.ts
8470
- import { Command as Command96 } from "commander";
8601
+ import { Command as Command97 } from "commander";
8471
8602
 
8472
8603
  // src/commands/cron/shared.ts
8473
8604
  async function cronClient(cmd) {
@@ -8528,7 +8659,7 @@ function printRows2(rows2) {
8528
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>")`);
8529
8660
 
8530
8661
  // src/commands/cron/create.ts
8531
- 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) => {
8532
8663
  const client = await cronClient(cmd);
8533
8664
  try {
8534
8665
  const service = await client.createCronService(name);
@@ -8545,8 +8676,8 @@ var createCommand9 = new Command96("create").description("make a cron service: a
8545
8676
  });
8546
8677
 
8547
8678
  // src/commands/cron/info.ts
8548
- import { Command as Command97 } from "commander";
8549
- 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) => {
8550
8681
  const client = await cronClient(cmd);
8551
8682
  try {
8552
8683
  const service = await client.getCronService(name);
@@ -8570,8 +8701,8 @@ var infoCommand2 = new Command97("info").alias("get").description("show a cron s
8570
8701
  });
8571
8702
 
8572
8703
  // src/commands/cron/ls.ts
8573
- import { Command as Command98 } from "commander";
8574
- 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) => {
8575
8706
  const client = await cronClient(cmd);
8576
8707
  try {
8577
8708
  const services = await client.listCronServices({ all: opts.all });
@@ -8591,8 +8722,8 @@ var lsCommand15 = new Command98("ls").alias("list").description("list cron servi
8591
8722
  });
8592
8723
 
8593
8724
  // src/commands/cron/rm.ts
8594
- import { Command as Command99 } from "commander";
8595
- 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) => {
8596
8727
  const client = await cronClient(cmd);
8597
8728
  try {
8598
8729
  if (!await confirm(`Delete cron service ${name}? Its triggers stop firing and their run history is deleted.`, opts.yes ?? false)) {
@@ -8608,10 +8739,10 @@ var rmCommand14 = new Command99("rm").alias("remove").description("delete a cron
8608
8739
  });
8609
8740
 
8610
8741
  // src/commands/cron/trigger/index.ts
8611
- import { Command as Command107 } from "commander";
8742
+ import { Command as Command108 } from "commander";
8612
8743
 
8613
8744
  // src/commands/cron/trigger/add.ts
8614
- import { Command as Command100 } from "commander";
8745
+ import { Command as Command101 } from "commander";
8615
8746
  function portOf(value) {
8616
8747
  const n2 = Number(value);
8617
8748
  if (!Number.isInteger(n2) || n2 < 1 || n2 > 65535) throw new KvboxError(`--port ${value}: a port is a number from 1 to 65535`);
@@ -8631,7 +8762,7 @@ function timeoutOf(value) {
8631
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`);
8632
8763
  return sec;
8633
8764
  }
8634
- 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) => {
8635
8766
  let action;
8636
8767
  if (opts.run !== void 0) {
8637
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");
@@ -8658,8 +8789,8 @@ var addCommand3 = new Command100("add").description("add a trigger: on a schedul
8658
8789
  });
8659
8790
 
8660
8791
  // src/commands/cron/trigger/ls.ts
8661
- import { Command as Command101 } from "commander";
8662
- 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) => {
8663
8794
  const client = await cronClient(cmd);
8664
8795
  try {
8665
8796
  const triggers = await client.listCronTriggers(service);
@@ -8675,8 +8806,8 @@ var lsCommand16 = new Command101("ls").alias("list").description("list a cron se
8675
8806
  });
8676
8807
 
8677
8808
  // src/commands/cron/trigger/pause.ts
8678
- import { Command as Command102 } from "commander";
8679
- 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) => {
8680
8811
  const client = await cronClient(cmd);
8681
8812
  try {
8682
8813
  const trigger = await client.setCronTriggerEnabled(service, id, false);
@@ -8691,8 +8822,8 @@ var pauseCommand2 = new Command102("pause").description("stop a trigger from fir
8691
8822
  });
8692
8823
 
8693
8824
  // src/commands/cron/trigger/resume.ts
8694
- import { Command as Command103 } from "commander";
8695
- 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) => {
8696
8827
  const client = await cronClient(cmd);
8697
8828
  try {
8698
8829
  const trigger = await client.setCronTriggerEnabled(service, id, true);
@@ -8707,8 +8838,8 @@ var resumeCommand2 = new Command103("resume").description("let a paused trigger
8707
8838
  });
8708
8839
 
8709
8840
  // src/commands/cron/trigger/rm.ts
8710
- import { Command as Command104 } from "commander";
8711
- 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) => {
8712
8843
  const client = await cronClient(cmd);
8713
8844
  try {
8714
8845
  if (!await confirm(`Delete trigger ${id} of cron service ${service}? Its run history is deleted too.`, opts.yes ?? false)) {
@@ -8724,8 +8855,8 @@ var rmCommand15 = new Command104("rm").alias("remove").description("delete a tri
8724
8855
  });
8725
8856
 
8726
8857
  // src/commands/cron/trigger/run.ts
8727
- import { Command as Command105 } from "commander";
8728
- 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) => {
8729
8860
  const client = await cronClient(cmd);
8730
8861
  try {
8731
8862
  const trigger = await client.runCronTrigger(service, id);
@@ -8741,13 +8872,13 @@ var runCommand = new Command105("run").description("fire a trigger now, once, be
8741
8872
  });
8742
8873
 
8743
8874
  // src/commands/cron/trigger/runs.ts
8744
- import { Command as Command106 } from "commander";
8875
+ import { Command as Command107 } from "commander";
8745
8876
  function limitOf(value) {
8746
8877
  const n2 = Number(value);
8747
8878
  if (!Number.isInteger(n2) || n2 < 1) throw new KvboxError(`-n ${value}: a number of runs, 1 or more`);
8748
8879
  return n2;
8749
8880
  }
8750
- 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) => {
8751
8882
  const limit = limitOf(opts.limit);
8752
8883
  const client = await cronClient(cmd);
8753
8884
  try {
@@ -8777,10 +8908,10 @@ var runsCommand = new Command106("runs").aliases(["logs"]).description("show how
8777
8908
  });
8778
8909
 
8779
8910
  // src/commands/cron/trigger/index.ts
8780
- 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);
8781
8912
 
8782
8913
  // src/commands/cron/index.ts
8783
- 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);
8784
8915
  var withOrg3 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal cron services)");
8785
8916
  for (const cmd of cronCommand.commands) {
8786
8917
  if (cmd === triggerCommand) cmd.commands.forEach(withOrg3);
@@ -8788,13 +8919,13 @@ for (const cmd of cronCommand.commands) {
8788
8919
  }
8789
8920
 
8790
8921
  // src/commands/managed/kind.ts
8791
- import { Command as Command127 } from "commander";
8922
+ import { Command as Command128 } from "commander";
8792
8923
 
8793
8924
  // src/commands/managed/backup/index.ts
8794
- import { Command as Command115 } from "commander";
8925
+ import { Command as Command116 } from "commander";
8795
8926
 
8796
8927
  // src/commands/managed/backup/create.ts
8797
- import { Command as Command110 } from "commander";
8928
+ import { Command as Command111 } from "commander";
8798
8929
 
8799
8930
  // src/commands/managed/shared.ts
8800
8931
  import "commander";
@@ -8881,7 +9012,7 @@ function parseStorage(text2, flag) {
8881
9012
  }
8882
9013
 
8883
9014
  // src/commands/managed/backup/create.ts
8884
- 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) => {
8885
9016
  const client = await managedClient(cmd);
8886
9017
  const ls = `kvbox ${spec.command} backup ls ${name}`;
8887
9018
  try {
@@ -8908,7 +9039,7 @@ var createCommand10 = (spec) => new Command110("create").description("back up a
8908
9039
  });
8909
9040
 
8910
9041
  // src/commands/managed/backup/ls.ts
8911
- import { Command as Command111 } from "commander";
9042
+ import { Command as Command112 } from "commander";
8912
9043
  var lsCommand17 = (spec) => {
8913
9044
  const removedOnes = async (err, name, client) => {
8914
9045
  if (!(err instanceof CallError && err.status === 404)) throw err;
@@ -8917,7 +9048,7 @@ var lsCommand17 = (spec) => {
8917
9048
  const own = name.includes("/") ? [] : gone.filter((b) => b.owner === me(client));
8918
9049
  return own.length > 0 ? own : gone;
8919
9050
  };
8920
- 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) => {
8921
9052
  const client = await managedClient(cmd);
8922
9053
  try {
8923
9054
  const list = name === void 0 ? await client.listManagedBackups(spec.kind) : await client.managedBackups(spec.kind, name).catch((err) => removedOnes(err, name, client));
@@ -8960,8 +9091,8 @@ var lsCommand17 = (spec) => {
8960
9091
  };
8961
9092
 
8962
9093
  // src/commands/managed/backup/restore.ts
8963
- import { Command as Command112 } from "commander";
8964
- 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) => {
8965
9096
  const client = await managedClient(cmd);
8966
9097
  try {
8967
9098
  const backup = await client.managedBackup(spec.kind, name, id);
@@ -8983,8 +9114,8 @@ var restoreCommand4 = (spec) => new Command112("restore").description("put a bac
8983
9114
  });
8984
9115
 
8985
9116
  // src/commands/managed/backup/rm.ts
8986
- import { Command as Command113 } from "commander";
8987
- 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) => {
8988
9119
  const client = await managedClient(cmd);
8989
9120
  try {
8990
9121
  await removeListed(client, await client.listManagedBackups(spec.kind), (b) => b.name, name, id, `database ${name}`, opts.yes ?? false);
@@ -8994,8 +9125,8 @@ var rmCommand16 = (spec) => new Command113("rm").alias("remove").description("re
8994
9125
  });
8995
9126
 
8996
9127
  // src/commands/managed/backup/schedule.ts
8997
- import { Command as Command114 } from "commander";
8998
- 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(
8999
9130
  async (name, flags, cmd) => {
9000
9131
  const change = changeOf(flags);
9001
9132
  const client = await managedClient(cmd);
@@ -9011,18 +9142,18 @@ var scheduleCommand4 = (spec) => scheduleFlags(new Command114("schedule").descri
9011
9142
 
9012
9143
  // src/commands/managed/backup/index.ts
9013
9144
  var backupCommand4 = (spec) => {
9014
- 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");
9015
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)"));
9016
9147
  return command;
9017
9148
  };
9018
9149
 
9019
9150
  // src/commands/managed/create.ts
9020
- import { Command as Command116 } from "commander";
9151
+ import { Command as Command117 } from "commander";
9021
9152
  import { setTimeout as sleep5 } from "timers/promises";
9022
9153
  var READY_WAIT_MS = 9e4;
9023
9154
  var READY_STEP_MS = 2e3;
9024
9155
  var createCommand11 = (spec) => {
9025
- 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");
9026
9157
  for (const o of spec.options) command.option(`--${o.name} <${o.arg}>`, o.help);
9027
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) => {
9028
9159
  const options = Object.fromEntries(spec.options.flatMap((o) => typeof opts[o.name] === "string" ? [[o.name, opts[o.name]]] : []));
@@ -9071,8 +9202,8 @@ var createCommand11 = (spec) => {
9071
9202
  };
9072
9203
 
9073
9204
  // src/commands/managed/grow.ts
9074
- import { Command as Command117 } from "commander";
9075
- 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) => {
9076
9207
  const storageGib = parseStorage(size, "size");
9077
9208
  const client = await managedClient(cmd);
9078
9209
  try {
@@ -9085,8 +9216,8 @@ var growCommand3 = (spec) => new Command117("grow").description("give a database
9085
9216
  });
9086
9217
 
9087
9218
  // src/commands/managed/info.ts
9088
- import { Command as Command118 } from "commander";
9089
- 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) => {
9090
9221
  const client = await managedClient(cmd);
9091
9222
  try {
9092
9223
  const m = await client.getManaged(spec.kind, name);
@@ -9098,8 +9229,8 @@ var infoCommand3 = (spec) => new Command118("info").alias("get").description("sh
9098
9229
  });
9099
9230
 
9100
9231
  // src/commands/managed/link.ts
9101
- import { Command as Command119 } from "commander";
9102
- 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) => {
9103
9234
  const client = await managedClient(cmd);
9104
9235
  try {
9105
9236
  const m = await spin(`linking ${box2} to ${name}\u2026`, client.linkManaged(spec.kind, name, box2));
@@ -9115,7 +9246,7 @@ var linkCommand2 = (spec) => new Command119("link").description("let a box reach
9115
9246
  });
9116
9247
 
9117
9248
  // src/commands/managed/ls.ts
9118
- import { Command as Command120 } from "commander";
9249
+ import { Command as Command121 } from "commander";
9119
9250
  function listRows(items, user, kindColumn) {
9120
9251
  return items.map((m) => ({
9121
9252
  owner: m.owner === user ? "private" : m.owner,
@@ -9129,7 +9260,7 @@ function listRows(items, user, kindColumn) {
9129
9260
  created: age(m.createdAt)
9130
9261
  }));
9131
9262
  }
9132
- 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) => {
9133
9264
  const client = await managedClient(cmd);
9134
9265
  try {
9135
9266
  const items = await client.listManaged(spec?.kind, { all: opts.all });
@@ -9149,8 +9280,8 @@ var lsCommand18 = (spec) => new Command120("ls").alias("list").description(spec
9149
9280
  });
9150
9281
 
9151
9282
  // src/commands/managed/password.ts
9152
- import { Command as Command121 } from "commander";
9153
- 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) => {
9154
9285
  const client = await managedClient(cmd);
9155
9286
  try {
9156
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);
@@ -9166,8 +9297,8 @@ var passwordCommand = (spec) => new Command121("password").description("show a d
9166
9297
  });
9167
9298
 
9168
9299
  // src/commands/managed/public.ts
9169
- import { Command as Command122 } from "commander";
9170
- 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) => {
9171
9302
  if (state !== "on" && state !== "off") throw new KvboxError(`write on or off: kvbox ${spec.command} public ${name} on`);
9172
9303
  const client = await managedClient(cmd);
9173
9304
  try {
@@ -9188,8 +9319,8 @@ var publicCommand2 = (spec) => new Command122("public").description("open a data
9188
9319
  });
9189
9320
 
9190
9321
  // src/commands/managed/rm.ts
9191
- import { Command as Command123 } from "commander";
9192
- 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) => {
9193
9324
  const client = await managedClient(cmd);
9194
9325
  try {
9195
9326
  if (!await confirm(`Delete database ${name} and all its data? There is no backup.`, opts.yes ?? false)) {
@@ -9205,8 +9336,8 @@ var rmCommand17 = (spec) => new Command123("rm").alias("remove").description("de
9205
9336
  });
9206
9337
 
9207
9338
  // src/commands/managed/start.ts
9208
- import { Command as Command124 } from "commander";
9209
- 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) => {
9210
9341
  const client = await managedClient(cmd);
9211
9342
  try {
9212
9343
  const m = await spin(`starting ${name}\u2026`, client.startManaged(spec.kind, name));
@@ -9218,8 +9349,8 @@ var startCommand2 = (spec) => new Command124("start").description("run a stopped
9218
9349
  });
9219
9350
 
9220
9351
  // src/commands/managed/stop.ts
9221
- import { Command as Command125 } from "commander";
9222
- 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) => {
9223
9354
  const client = await managedClient(cmd);
9224
9355
  try {
9225
9356
  const m = await spin(`stopping ${name}\u2026`, client.stopManaged(spec.kind, name));
@@ -9231,8 +9362,8 @@ var stopCommand2 = (spec) => new Command125("stop").description("shut a database
9231
9362
  });
9232
9363
 
9233
9364
  // src/commands/managed/unlink.ts
9234
- import { Command as Command126 } from "commander";
9235
- 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) => {
9236
9367
  const client = await managedClient(cmd);
9237
9368
  try {
9238
9369
  const m = await spin(`unlinking ${box2} from ${name}\u2026`, client.unlinkManaged(spec.kind, name, box2));
@@ -9245,7 +9376,7 @@ var unlinkCommand2 = (spec) => new Command126("unlink").description("stop a box
9245
9376
 
9246
9377
  // src/commands/managed/kind.ts
9247
9378
  function kindCommand(spec, description) {
9248
- const command = new Command127(spec.command).aliases(spec.aliases).description(description);
9379
+ const command = new Command128(spec.command).aliases(spec.aliases).description(description);
9249
9380
  for (const make of [createCommand11, lsCommand18, infoCommand3, passwordCommand, publicCommand2, linkCommand2, unlinkCommand2, growCommand3, stopCommand2, startCommand2, rmCommand17]) {
9250
9381
  command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
9251
9382
  }
@@ -9260,14 +9391,14 @@ var pgCommand = kindCommand(POSTGRES2, "managed PostgreSQL: a database kvbox run
9260
9391
  var redisCommand = kindCommand(REDIS, "managed Redis (Valkey): a Redis kvbox runs for you, private until you link a box or make it public");
9261
9392
 
9262
9393
  // src/commands/managed/index.ts
9263
- import { Command as Command128 } from "commander";
9264
- 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)"));
9265
9396
 
9266
9397
  // src/commands/env/index.ts
9267
- import { Command as Command132 } from "commander";
9398
+ import { Command as Command133 } from "commander";
9268
9399
 
9269
9400
  // src/commands/env/ls.ts
9270
- import { Command as Command129 } from "commander";
9401
+ import { Command as Command130 } from "commander";
9271
9402
 
9272
9403
  // src/commands/env/shared.ts
9273
9404
  function requireCloud4(client) {
@@ -9294,7 +9425,7 @@ function firstBootHint(box2, name) {
9294
9425
  }
9295
9426
 
9296
9427
  // src/commands/env/ls.ts
9297
- 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) => {
9298
9429
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
9299
9430
  try {
9300
9431
  if (opts.box !== void 0) {
@@ -9333,8 +9464,8 @@ var lsCommand19 = new Command129("ls").alias("list").description("list the varia
9333
9464
  });
9334
9465
 
9335
9466
  // src/commands/env/rm.ts
9336
- import { Command as Command130 } from "commander";
9337
- 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) => {
9338
9469
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
9339
9470
  try {
9340
9471
  const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
@@ -9371,8 +9502,8 @@ var rmCommand18 = new Command130("rm").alias("remove").description("remove varia
9371
9502
  });
9372
9503
 
9373
9504
  // src/commands/env/set.ts
9374
- import { Command as Command131 } from "commander";
9375
- 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) => {
9376
9507
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
9377
9508
  try {
9378
9509
  const owner = opts.box === void 0 ? requireCloud4(client) : void 0;
@@ -9409,14 +9540,14 @@ var setCommand2 = new Command131("set").description("add or change a variable; b
9409
9540
  });
9410
9541
 
9411
9542
  // src/commands/env/index.ts
9412
- 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);
9413
9544
  for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
9414
9545
 
9415
9546
  // src/commands/domain/index.ts
9416
- import { Command as Command136 } from "commander";
9547
+ import { Command as Command137 } from "commander";
9417
9548
 
9418
9549
  // src/commands/domain/add.ts
9419
- import { Command as Command133 } from "commander";
9550
+ import { Command as Command134 } from "commander";
9420
9551
 
9421
9552
  // src/commands/domain/shared.ts
9422
9553
  function requireCloud5(client) {
@@ -9436,7 +9567,7 @@ function hostIn(name, zone) {
9436
9567
  }
9437
9568
 
9438
9569
  // src/commands/domain/add.ts
9439
- 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) => {
9440
9571
  const domain = assertDomain(domainArg.trim().toLowerCase());
9441
9572
  const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
9442
9573
  const client = await clientFor(cmd.optsWithGlobals());
@@ -9472,8 +9603,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
9472
9603
  });
9473
9604
 
9474
9605
  // src/commands/domain/ls.ts
9475
- import { Command as Command134 } from "commander";
9476
- 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) => {
9477
9608
  const client = await clientFor(cmd.optsWithGlobals());
9478
9609
  try {
9479
9610
  requireCloud5(client);
@@ -9502,8 +9633,8 @@ var lsCommand20 = new Command134("ls").alias("list").description("list your cust
9502
9633
  });
9503
9634
 
9504
9635
  // src/commands/domain/rm.ts
9505
- import { Command as Command135 } from "commander";
9506
- 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) => {
9507
9638
  const domain = domainArg.trim().toLowerCase();
9508
9639
  const client = await clientFor(cmd.optsWithGlobals());
9509
9640
  try {
@@ -9524,7 +9655,7 @@ var rmCommand19 = new Command135("rm").alias("remove").description("stop serving
9524
9655
  });
9525
9656
 
9526
9657
  // src/commands/domain/index.ts
9527
- 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);
9528
9659
  for (const cmd of domainCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
9529
9660
 
9530
9661
  // src/commands/update.ts
@@ -9532,7 +9663,7 @@ import { spawn as spawn8 } from "child_process";
9532
9663
  import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
9533
9664
  import { tmpdir } from "os";
9534
9665
  import { join as join9 } from "path";
9535
- import { Command as Command137 } from "commander";
9666
+ import { Command as Command138 } from "commander";
9536
9667
 
9537
9668
  // src/update.ts
9538
9669
  import { mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
@@ -9651,7 +9782,7 @@ function run2(cmd, args) {
9651
9782
  child.on("exit", (code, signal) => resolve4(code ?? (signal ? 1 : 0)));
9652
9783
  });
9653
9784
  }
9654
- 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 () => {
9655
9786
  suppressUpdateNotice();
9656
9787
  const inst = installerFor(process.platform, process.env["KVBOX_INSTALL_URL"] || INSTALL_BASE);
9657
9788
  let code;
@@ -9671,6 +9802,251 @@ var selfUpdateCommand = new Command137("update").description("update kvbox to th
9671
9802
  if (code !== 0) throw new KvboxError(`the installer failed (exit ${code})`, code);
9672
9803
  });
9673
9804
 
9805
+ // src/commands/sshConfig.ts
9806
+ import { chmod as chmod2, mkdir as mkdir4, readFile as readFile9, writeFile as writeFile5 } from "fs/promises";
9807
+ import { homedir as homedir2 } from "os";
9808
+ import { dirname as dirname2, join as join11 } from "path";
9809
+ import { Command as Command139 } from "commander";
9810
+
9811
+ // src/sshConfig.ts
9812
+ import { spawnSync as spawnSync4 } from "child_process";
9813
+ import { createHmac as createHmac2 } from "crypto";
9814
+ import { readFile as readFile8, writeFile as writeFile4 } from "fs/promises";
9815
+ import { join as join10 } from "path";
9816
+ var SSH_SUFFIX = ".kvbox";
9817
+ var BEGIN_MARK = "# BEGIN kvbox (managed by `kvbox ssh-config`; do not edit between markers)";
9818
+ var END_MARK = "# END kvbox";
9819
+ function sshAlias(box2, me2) {
9820
+ const slug = slugOf(box2.owner);
9821
+ return me2 === void 0 || slug === me2 ? `${box2.name}${SSH_SUFFIX}` : `${box2.name}.${slug}${SSH_SUFFIX}`;
9822
+ }
9823
+ function parseAlias(alias) {
9824
+ const lower = alias.toLowerCase();
9825
+ if (!lower.endsWith(SSH_SUFFIX)) return void 0;
9826
+ const parts = lower.slice(0, -SSH_SUFFIX.length).split(".");
9827
+ if (parts.some((p) => p === "")) return void 0;
9828
+ if (parts.length === 1) return { name: parts[0] };
9829
+ if (parts.length === 2) return { name: parts[0], slug: parts[1] };
9830
+ return void 0;
9831
+ }
9832
+ function configPath(path, platform = process.platform) {
9833
+ return `"${platform === "win32" ? path.replaceAll("\\", "/") : path}"`;
9834
+ }
9835
+ function launcher() {
9836
+ return [process.execPath, ...process.execArgv, process.argv[1]];
9837
+ }
9838
+ function renderBlock(o) {
9839
+ const platform = o.platform ?? process.platform;
9840
+ const slash = (s) => platform === "win32" ? s.replaceAll("\\", "/") : s;
9841
+ const flags = o.local ? ["--local"] : [];
9842
+ const args = [...o.kvbox.map(slash), ...flags, "ssh-proxy"];
9843
+ const proxy = [...args.map((a) => `"${a}"`), "%n"].join(" ");
9844
+ const renew = o.renewWith !== void 0 ? [slash(o.renewWith), ...flags, "ssh-proxy"] : args;
9845
+ const exec = [...renew.map((a) => /\s/.test(a) ? `'${a}'` : a), "--renew", "%n"].join(" ");
9846
+ return [
9847
+ BEGIN_MARK,
9848
+ `Match originalhost *${SSH_SUFFIX} exec "${exec}"`,
9849
+ " User kvbox",
9850
+ ` IdentityFile ${configPath(o.p.sshKey, platform)}`,
9851
+ " IdentitiesOnly yes",
9852
+ ` UserKnownHostsFile ${configPath(o.p.sshKnownHosts, platform)}`,
9853
+ " StrictHostKeyChecking accept-new",
9854
+ " HashKnownHosts no",
9855
+ " ServerAliveInterval 60",
9856
+ " SetEnv LC_ALL=C.UTF-8",
9857
+ ` ProxyCommand ${proxy}`,
9858
+ ...o.hosts.map((h) => `Host ${h}`),
9859
+ // Whatever follows the block in the file applies to every host again, as it did before.
9860
+ "Host *",
9861
+ END_MARK
9862
+ ].join("\n");
9863
+ }
9864
+ async function windowsLauncher(kvbox, p) {
9865
+ const file = join10(p.ssh, "kvbox-ssh.cmd");
9866
+ await writeFile4(file, `@${kvbox.map((a) => `"${a}"`).join(" ")} %*\r
9867
+ `);
9868
+ if (!/\s/.test(file)) return file;
9869
+ const res = spawnSync4("cmd.exe", ["/d", "/c", `for %I in ("${file}") do @echo %~sI`], { encoding: "utf8" });
9870
+ const short = res.status === 0 ? res.stdout.trim() : "";
9871
+ return short !== "" && !/\s/.test(short) ? short : file;
9872
+ }
9873
+ function spliceBlock(text2, block5) {
9874
+ const eol = text2.includes("\r\n") ? "\r\n" : "\n";
9875
+ const lines = text2.split(/\r?\n/);
9876
+ const begin = lines.findIndex((l) => l.trim().startsWith("# BEGIN kvbox"));
9877
+ const end = begin === -1 ? -1 : lines.findIndex((l, i) => i > begin && l.trim() === END_MARK);
9878
+ const add = block5 === void 0 ? [] : block5.split("\n");
9879
+ let out;
9880
+ if (begin !== -1 && end !== -1) {
9881
+ const after = lines.slice(end + 1);
9882
+ if (block5 === void 0 && after[0] === "") after.shift();
9883
+ out = [...lines.slice(0, begin), ...add, ...after];
9884
+ } else {
9885
+ if (block5 === void 0) return text2;
9886
+ const rest = text2 === "" ? [] : ["", ...lines];
9887
+ out = [...add, ...rest];
9888
+ }
9889
+ let joined = out.join(eol);
9890
+ if (joined !== "" && !joined.endsWith(eol)) joined += eol;
9891
+ return joined;
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
+ }
9905
+ var idsFile = (p) => join10(p.ssh, "ssh-config.json");
9906
+ function namesHost(line, alias) {
9907
+ const field = line.trim().split(/\s+/)[0] ?? "";
9908
+ if (field.startsWith("#") || field === "") return false;
9909
+ return field.split(",").some((h) => {
9910
+ if (!h.startsWith("|1|")) return h.toLowerCase() === alias || h.toLowerCase() === `[${alias}]:22`;
9911
+ const [, , salt, hash] = h.split("|");
9912
+ if (salt === void 0 || hash === void 0) return false;
9913
+ return createHmac2("sha1", Buffer.from(salt, "base64")).update(alias).digest("base64") === hash;
9914
+ });
9915
+ }
9916
+ async function forgetReplacedBox(alias, id, p) {
9917
+ const ids = await readFile8(idsFile(p), "utf8").then((t) => JSON.parse(t), () => ({}));
9918
+ if (ids[alias] === id) return;
9919
+ if (ids[alias] !== void 0) {
9920
+ const text2 = await readFile8(p.sshKnownHosts, "utf8").catch(() => null);
9921
+ if (text2 !== null) {
9922
+ const kept = text2.split("\n").filter((l) => !namesHost(l, alias));
9923
+ await writeFile4(p.sshKnownHosts, kept.join("\n"));
9924
+ }
9925
+ }
9926
+ ids[alias] = id;
9927
+ await writeFile4(idsFile(p), JSON.stringify(ids, null, 2) + "\n");
9928
+ }
9929
+
9930
+ // src/commands/sshConfig.ts
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) => {
9932
+ const file = opts.file ?? join11(homedir2(), ".ssh", "config");
9933
+ const before = await readFile9(file, "utf8").catch((err) => {
9934
+ if (err.code === "ENOENT") return "";
9935
+ throw err;
9936
+ });
9937
+ if (opts.remove && boxes.length === 0) {
9938
+ const after = spliceBlock(before, void 0);
9939
+ const removed = after !== before;
9940
+ if (removed) await writeFile5(file, after);
9941
+ if (opts.json) return json({ file, removed, hosts: [] });
9942
+ info(removed ? `took the kvbox block out of ${file}` : `${file} has no kvbox block`);
9943
+ return;
9944
+ }
9945
+ const globals = cmd.optsWithGlobals();
9946
+ const client = await clientFor(globals);
9947
+ let named;
9948
+ let all = [];
9949
+ try {
9950
+ await ensureCert(client);
9951
+ named = await aliasesOf(client, boxes, opts.remove === true);
9952
+ if (boxes.length === 0) all = named;
9953
+ } finally {
9954
+ await client.close();
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));
9959
+ const p = paths();
9960
+ const kvbox = launcher();
9961
+ const renewWith = process.platform === "win32" ? await windowsLauncher(kvbox, p) : void 0;
9962
+ const block5 = renderBlock({ kvbox, renewWith, local: globals.local === true, hosts, p });
9963
+ await mkdir4(dirname2(file), { recursive: true, mode: 448 });
9964
+ const fresh = before === "";
9965
+ await writeFile5(file, spliceBlock(before, block5));
9966
+ if (fresh) await chmod2(file, 384).catch(() => void 0);
9967
+ if (opts.json) return json({ file, removed: false, hosts });
9968
+ if (client.target.kind === "cloud" && client.target.env === true) {
9969
+ warn("KVBOX_TOKEN is set in this shell only: ssh started elsewhere (VS Code) uses your kvbox login instead");
9970
+ }
9971
+ info(`wrote the kvbox block to ${file}`);
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");
9974
+ else {
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]}`);
9977
+ }
9978
+ info(color.dim("any other box works as <box>.kvbox too; kvbox ssh-config <box> adds it to the list"));
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
+ }
9994
+
9995
+ // src/commands/sshProxy.ts
9996
+ import { connect } from "net";
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) => {
9999
+ const ref = parseAlias(host);
10000
+ if (ref === void 0) throw new KvboxError(`${host}: not a kvbox name (<box>.kvbox or <box>.<org>.kvbox)`);
10001
+ const client = await clientFor(cmd.optsWithGlobals());
10002
+ if (opts.renew) {
10003
+ try {
10004
+ await ensureCert(client);
10005
+ } catch (err) {
10006
+ process.stderr.write(`kvbox: ${err.message}
10007
+ `);
10008
+ } finally {
10009
+ await client.close();
10010
+ }
10011
+ return;
10012
+ }
10013
+ let ep;
10014
+ let id;
10015
+ try {
10016
+ const mine = me(client);
10017
+ const text2 = ref.slug !== void 0 ? `${ref.slug}/${ref.name}` : mine !== void 0 ? `${mine}/${ref.name}` : ref.name;
10018
+ let box2 = pickRef(await boxesFor(client, text2), text2, mine);
10019
+ if (!box2) throw new KvboxError(`box ${ref.slug !== void 0 ? text2 : ref.name}: not found (kvbox ls)`);
10020
+ await ensureCert(client, void 0, void 0, { owner: box2.owner });
10021
+ const wasRunning = box2.status === "running";
10022
+ if (!wasRunning) box2 = await wakeUp(client, box2, ref.name);
10023
+ ep = sshEndpoint(box2, client.target);
10024
+ id = box2.id;
10025
+ if (!wasRunning) await waitForSsh(ep);
10026
+ } finally {
10027
+ await client.close();
10028
+ }
10029
+ await forgetReplacedBox(host.toLowerCase(), id, paths());
10030
+ await pipe(ep.host, ep.port);
10031
+ });
10032
+ function pipe(host, port) {
10033
+ return new Promise((resolve4, reject) => {
10034
+ const sock = connect({ host, port });
10035
+ sock.setNoDelay(true);
10036
+ sock.once("connect", () => {
10037
+ process.stdin.pipe(sock);
10038
+ sock.pipe(process.stdout);
10039
+ });
10040
+ sock.once("error", (err) => reject(new KvboxError(`could not reach ${host}:${port}: ${err.message}`)));
10041
+ process.stdin.once("end", () => sock.end());
10042
+ sock.once("close", () => {
10043
+ process.stdin.unpipe(sock);
10044
+ process.stdin.destroy();
10045
+ resolve4();
10046
+ });
10047
+ });
10048
+ }
10049
+
9674
10050
  // src/help.ts
9675
10051
  import pc2 from "picocolors";
9676
10052
  var c = pc2.createColors(true);
@@ -9732,6 +10108,7 @@ var HELP_GROUPS = [
9732
10108
  ["login", "log in to the kvbox cloud or your own control plane"],
9733
10109
  ["logout", "log out; commands target this machine again"],
9734
10110
  ["whoami", "show the account and control plane in use"],
10111
+ ["ssh-config", "let ssh and VS Code Remote-SSH reach your boxes as <box>.kvbox"],
9735
10112
  ["key", "API keys for programs: CI, agents, the SDK"],
9736
10113
  ["org", "shared slugs that own boxes, with owners, admins and members"],
9737
10114
  ["usage", "what your boxes and volumes used, and what it cost"],
@@ -9780,7 +10157,7 @@ function installRootHelp(program) {
9780
10157
 
9781
10158
  // src/program.ts
9782
10159
  function buildProgram() {
9783
- const program = new Command138("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();
9784
10161
  program.addCommand(vmCommand);
9785
10162
  program.addCommand(snapshotsCommand);
9786
10163
  program.addCommand(volumeCommand);
@@ -9802,6 +10179,8 @@ function buildProgram() {
9802
10179
  program.addCommand(redeemCommand);
9803
10180
  program.addCommand(deployCommand);
9804
10181
  program.addCommand(selfUpdateCommand);
10182
+ program.addCommand(sshConfigCommand);
10183
+ program.addCommand(sshProxyCommand, { hidden: true });
9805
10184
  for (const cmd of vmAliases) program.addCommand(cmd);
9806
10185
  installRootHelp(program);
9807
10186
  return program;