@kvbox/cli 0.6.15 → 0.6.17

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
@@ -62,13 +62,13 @@ async function confirm(question, yes) {
62
62
  rl.close();
63
63
  }
64
64
  }
65
- function gb(bytes) {
66
- const g = bytes / 1024 ** 3;
65
+ function gb(bytes2) {
66
+ const g = bytes2 / 1024 ** 3;
67
67
  if (g >= 1) return `${Number.isInteger(g) ? g : g.toFixed(1)} GB`;
68
- return `${Math.round(bytes / 1024 ** 2)} MB`;
68
+ return `${Math.round(bytes2 / 1024 ** 2)} MB`;
69
69
  }
70
- function gbShort(bytes) {
71
- return gb(bytes).replace(" ", "");
70
+ function gbShort(bytes2) {
71
+ return gb(bytes2).replace(" ", "");
72
72
  }
73
73
  function shape(vcpu, memMib, diskBytes) {
74
74
  const cpuRam = `${vcpu}\xD7${gbShort(memMib * 1024 ** 2)}`;
@@ -82,8 +82,8 @@ function status(s) {
82
82
  if (s === "standby" || s === "hibernated") return color.yellow(s);
83
83
  return color.dim(s);
84
84
  }
85
- function age(iso, now = Date.now()) {
86
- const sec = Math.max(0, Math.floor((now - Date.parse(iso)) / 1e3));
85
+ function age(iso2, now = Date.now()) {
86
+ const sec = Math.max(0, Math.floor((now - Date.parse(iso2)) / 1e3));
87
87
  if (sec < 60) return "just now";
88
88
  const min = Math.floor(sec / 60);
89
89
  if (min < 60) return `${min}m ago`;
@@ -155,7 +155,7 @@ async function spin(message, work, opts = {}) {
155
155
  }
156
156
 
157
157
  // src/program.ts
158
- import { Command as Command133 } from "commander";
158
+ import { Command as Command138 } 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.15" : void 0);
173
+ var VERSION = versionOf(import.meta.url, true ? "0.6.17" : void 0);
174
174
 
175
175
  // src/commands/vm/index.ts
176
- import { Command as Command39 } from "commander";
176
+ import { Command as Command42 } from "commander";
177
177
 
178
178
  // src/commands/vm/connect.ts
179
179
  import { spawnSync as spawnSync3 } from "child_process";
@@ -360,9 +360,9 @@ var INTEGRATION_STATUSES = ["ok", "needs-reconnect"];
360
360
  var IntegrationStatusSchema = z.enum(INTEGRATION_STATUSES);
361
361
  var INTEGRATIONS_OFF = "off";
362
362
  function parseIntegrationList(text2) {
363
- const names2 = text2.split(",").map((n) => n.trim().toLowerCase()).filter(Boolean);
363
+ const names2 = text2.split(",").map((n2) => n2.trim().toLowerCase()).filter(Boolean);
364
364
  if (names2.length === 0 || names2.length === 1 && names2[0] === INTEGRATIONS_OFF) return [];
365
- const unknown = names2.filter((n) => !INTEGRATION_IDS.includes(n));
365
+ const unknown = names2.filter((n2) => !INTEGRATION_IDS.includes(n2));
366
366
  if (unknown.length > 0) {
367
367
  const what = unknown[0] === INTEGRATIONS_OFF ? `${INTEGRATIONS_OFF} goes alone, not in a list` : `unknown integration: ${unknown.join(", ")}`;
368
368
  throw new KvboxError(`${what} (the integrations are: ${INTEGRATION_IDS.join(", ")}; ${INTEGRATIONS_OFF} for none)`);
@@ -376,7 +376,8 @@ var IntegrationCatalogEntrySchema = z.object({
376
376
  title: z.string(),
377
377
  description: z.string(),
378
378
  /**
379
- * How Connect works: `oauth` sends the browser to the provider's consent screen; `paste` takes a credential
379
+ * How Connect works: `oauth` sends the browser to the provider's consent screen (for an org's GitHub, the
380
+ * kvbox GitHub App's install screen); `paste` takes a credential
380
381
  * the user pastes (Claude Code's). A plain string, like `id`: a released CLI must still read a catalog with a way it does not know.
381
382
  */
382
383
  connect: z.string(),
@@ -407,11 +408,23 @@ var IntegrationSchema = z.object({
407
408
  connectedAt: z.string().nullable(),
408
409
  /** The last time a box was handed the credential (to the minute). */
409
410
  lastUsedAt: z.string().nullable(),
411
+ /** Where the connection is changed at the provider: a GitHub App installation's settings (its repositories, uninstalling it). */
412
+ manageUrl: z.string().optional(),
410
413
  /** Whether the caller may connect or disconnect it: the slug's own user, an org's owners. */
411
414
  canManage: z.boolean()
412
415
  });
413
416
  var IntegrationConnectSchema = z.object({ url: z.string() });
414
- var IntegrationCompleteRequestSchema = z.object({ code: z.string().min(1), state: z.string().min(1) });
417
+ var IntegrationCompleteRequestSchema = z.object({
418
+ code: z.string().min(1).optional(),
419
+ state: z.string().min(1),
420
+ installationId: z.string().regex(/^\d{1,15}$/).optional()
421
+ });
422
+ var IntegrationNextStepSchema = z.object({
423
+ next: z.enum(["install", "choose"]),
424
+ url: z.string(),
425
+ state: z.string().optional(),
426
+ choices: z.array(z.object({ installationId: z.string(), account: z.string() })).optional()
427
+ });
415
428
  var ClaudeConnectRequestSchema = z.object({
416
429
  credential: z.string().trim().min(1).max(4096).regex(/^[A-Za-z0-9_-]+$/, "a Claude Code token or an Anthropic API key has only letters, digits, - and _: paste it again on one line, with nothing inside it")
417
430
  });
@@ -449,9 +462,9 @@ var SIZE_NAMES = Object.keys(SIZES);
449
462
  function parseMib(text2) {
450
463
  const m = /^\s*(\d+(?:\.\d+)?)\s*([gm]i?b?)?\s*$/i.exec(text2);
451
464
  if (!m) return void 0;
452
- const n = Number(m[1]);
465
+ const n2 = Number(m[1]);
453
466
  const unit = (m[2] ?? "g").toLowerCase();
454
- const mib = unit.startsWith("m") ? n : n * 1024;
467
+ const mib = unit.startsWith("m") ? n2 : n2 * 1024;
455
468
  return Number.isInteger(mib) && mib > 0 ? mib : void 0;
456
469
  }
457
470
 
@@ -480,7 +493,25 @@ var PortsRequest = z2.object({
480
493
  });
481
494
  var BoxPortSchema = z2.number().int().min(1).max(65535);
482
495
  var BoxLinkSchema = z2.object({ from: z2.string(), port: BoxPortSchema });
483
- var LinkRequest = z2.object({ from: z2.string().min(1), fromOwner: z2.string().optional(), port: BoxPortSchema });
496
+ var LinkRequest = z2.object({
497
+ from: z2.string().min(1),
498
+ fromOwner: z2.string().optional(),
499
+ port: BoxPortSchema,
500
+ /**
501
+ * The box `from` is on another host (#207, a control plane's call only): no rule opens here. Its host
502
+ * connects to this host's HTTPS listener (`BOX_LINK_PATH_RE`) with `key`, which this link alone answers to.
503
+ */
504
+ far: z2.object({ key: z2.string().min(32) }).optional()
505
+ });
506
+ var FarLinkRequest = z2.object({
507
+ to: z2.string().min(1),
508
+ toOwner: z2.string().optional(),
509
+ port: BoxPortSchema,
510
+ url: z2.string().url(),
511
+ pin: z2.string().min(1),
512
+ key: z2.string().min(32)
513
+ });
514
+ var FarUnlinkRequest = FarLinkRequest.pick({ to: true, toOwner: true, port: true });
484
515
  var ClaimSubdomainRequest = z2.object({ name: z2.string(), port: BoxPortSchema });
485
516
  var SubdomainPortRequest = z2.object({ port: BoxPortSchema });
486
517
  var SubdomainRouteRequest = z2.object({ name: z2.string(), port: BoxPortSchema });
@@ -546,7 +577,10 @@ var BackupSchema = z2.object({
546
577
  dataBytes: z2.number().int().nullable(),
547
578
  /** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
548
579
  uploadedBytes: z2.number().int().nullable(),
580
+ /** Who asked for it; for a scheduled one, whoever made the thing it is of. */
549
581
  createdBy: z2.string().nullable(),
582
+ /** Taken by its nightly schedule (`backup-schedule`) rather than by a person: free, and outside the daily limit. */
583
+ scheduled: z2.boolean().default(false),
550
584
  createdAt: z2.string(),
551
585
  finishedAt: z2.string().nullable()
552
586
  });
@@ -596,7 +630,10 @@ var VolumeBackupSchema = z2.object({
596
630
  dataBytes: z2.number().int().nullable(),
597
631
  /** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
598
632
  uploadedBytes: z2.number().int().nullable(),
633
+ /** Who asked for it; for a scheduled one, whoever made the thing it is of. */
599
634
  createdBy: z2.string().nullable(),
635
+ /** Taken by its nightly schedule (`backup-schedule`) rather than by a person: free, and outside the daily limit. */
636
+ scheduled: z2.boolean().default(false),
600
637
  createdAt: z2.string(),
601
638
  finishedAt: z2.string().nullable()
602
639
  });
@@ -736,7 +773,7 @@ var MachineSchema = z2.object({
736
773
  ownerKind: z2.enum(["user", "org"]).optional(),
737
774
  /**
738
775
  * The name of the host the box runs on. Only the control plane fills it in, on `GET /machines`: a box
739
- * links to, and a volume attaches to, only a box on the same host.
776
+ * a volume attaches only to a box on the same host, and a link between two boxes of one host stays on it.
740
777
  */
741
778
  host: z2.string().optional(),
742
779
  /** The country code of that host (`RO`, `US`), when its admin gave one. Only the control plane fills it in. */
@@ -1037,6 +1074,8 @@ var CapacitySchema = z2.object({
1037
1074
  fromBackup: z2.boolean().optional(),
1038
1075
  /** True on a kvbox-server that keeps a box's `integrations` (#205); an older one drops the field without a word. */
1039
1076
  integrations: z2.boolean().optional(),
1077
+ /** True on a kvbox-server that carries a link to a box on another host (#207); the control plane links across hosts only between two such. */
1078
+ farLinks: z2.boolean().optional(),
1040
1079
  /** The integrations this kvbox-server knows (`hostKnowsIntegrations`). Absent with `integrations`: the first one's, `github` alone. */
1041
1080
  integrationIds: z2.array(z2.string()).optional()
1042
1081
  });
@@ -1724,7 +1763,54 @@ import { setTimeout as sleep2 } from "timers/promises";
1724
1763
  import { Agent, request } from "undici";
1725
1764
 
1726
1765
  // ../sdk/src/machines.ts
1766
+ import { z as z5 } from "zod";
1767
+
1768
+ // ../shared/src/traffic.ts
1727
1769
  import { z as z4 } from "zod";
1770
+ var TRAFFIC_SLOT_MS = 5 * 6e4;
1771
+ var TRAFFIC_KEEP_DAYS = 7;
1772
+ var TRAFFIC_KEEP_MS = TRAFFIC_KEEP_DAYS * 864e5;
1773
+ var LATENCY_BUCKETS_MS = [5, 10, 25, 50, 100, 250, 500, 1e3, 2500, 5e3, 1e4, 3e4];
1774
+ var LATENCY_BUCKET_COUNT = LATENCY_BUCKETS_MS.length + 1;
1775
+ var count = z4.number().int().nonnegative();
1776
+ var figures = {
1777
+ requests: count,
1778
+ s2xx: count,
1779
+ s3xx: count,
1780
+ s4xx: count,
1781
+ s5xx: count,
1782
+ bytesIn: count,
1783
+ bytesOut: count,
1784
+ wakes: count,
1785
+ /** The average wait of a request that woke the box, ms; null without one. */
1786
+ wakeWaitMs: count.nullable(),
1787
+ /** Null without an answer to measure. */
1788
+ p50Ms: count.nullable(),
1789
+ p95Ms: count.nullable()
1790
+ };
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(),
1798
+ /** The one host name asked for; null for all of the box's. */
1799
+ host: z4.string().nullable(),
1800
+ /** 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)
1804
+ });
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)
1813
+ });
1728
1814
 
1729
1815
  // ../sdk/src/errors.ts
1730
1816
  var KvboxSdkError = class extends Error {
@@ -1820,7 +1906,7 @@ var KvboxResponseError = class extends KvboxSdkError {
1820
1906
  var FORK_TIMEOUT_MS = 66e4;
1821
1907
  var listQuery = (opts) => opts.all ? "?all=1" : "";
1822
1908
  var box = (name, rest = "") => `/machines/${encodeURIComponent(name)}${rest}`;
1823
- var sleep = (ms) => new Promise((resolve4) => setTimeout(resolve4, ms));
1909
+ var sleep = (ms2) => new Promise((resolve4) => setTimeout(resolve4, ms2));
1824
1910
  var FROM_BACKUP_TIMEOUT_MS = 2 * 36e5;
1825
1911
  var passing = (err) => err instanceof KvboxConnectionError || err instanceof KvboxTimeoutError || err instanceof KvboxApiError && [502, 503, 504].includes(err.status);
1826
1912
  var Machines = class {
@@ -1836,7 +1922,7 @@ var Machines = class {
1836
1922
  ports;
1837
1923
  /** Every box the caller can read (their own and their orgs'), sorted by owner then name. */
1838
1924
  list(opts = {}) {
1839
- return this.transport.request("GET", `/machines${listQuery(opts)}`, z4.array(MachineSchema), { org: opts.org });
1925
+ return this.transport.request("GET", `/machines${listQuery(opts)}`, z5.array(MachineSchema), { org: opts.org });
1840
1926
  }
1841
1927
  /**
1842
1928
  * One box, found in the listing (the API has no route for a single box). `slug/name` looks in that
@@ -1850,7 +1936,7 @@ var Machines = class {
1850
1936
  async find(name, orgOpt, timeoutMs) {
1851
1937
  const slash = name.indexOf("/");
1852
1938
  const [org, bare] = slash === -1 ? [orgOpt, name] : [name.slice(0, slash), name.slice(slash + 1)];
1853
- const listing = await this.transport.request("GET", "/machines", z4.array(MachineSchema), { org, timeoutMs });
1939
+ const listing = await this.transport.request("GET", "/machines", z5.array(MachineSchema), { org, timeoutMs });
1854
1940
  const named = listing.filter((m) => m.name === bare && (slash === -1 || slugOf2(m.owner) === org));
1855
1941
  if (named.length <= 1) {
1856
1942
  if (named[0] !== void 0) return named[0];
@@ -1884,7 +1970,7 @@ var Machines = class {
1884
1970
  }
1885
1971
  /** Remove the box and its disk. */
1886
1972
  async remove(name, opts = {}) {
1887
- await this.transport.request("DELETE", box(name), z4.undefined(), { org: opts.org });
1973
+ await this.transport.request("DELETE", box(name), z5.undefined(), { org: opts.org });
1888
1974
  }
1889
1975
  /** Boot a stopped box. */
1890
1976
  start(name, opts = {}) {
@@ -2019,7 +2105,24 @@ var Machines = class {
2019
2105
  getExec(name, id, opts = {}) {
2020
2106
  return this.transport.request("GET", box(name, `/exec/${encodeURIComponent(id)}`), ExecSchema, { org: opts.org });
2021
2107
  }
2108
+ /**
2109
+ * What reached the box through its HTTPS names (`*.kvbox.app` and custom domains), counted by kvbox's edge in
2110
+ * five-minute slots kept 7 days: requests by status class, bytes, latency p50/p95 and requests that woke it.
2111
+ * The last 24 hours by default. Traffic on a published port or over SSH is not counted.
2112
+ */
2113
+ traffic(name, opts = {}) {
2114
+ return this.transport.request("GET", box(name, `/traffic${trafficQuery(opts)}`), TrafficReportSchema, { org: opts.org });
2115
+ }
2022
2116
  };
2117
+ var iso = (d) => typeof d === "string" ? d : d.toISOString();
2118
+ function trafficQuery(opts) {
2119
+ const q = new URLSearchParams();
2120
+ if (opts.since !== void 0) q.set("since", iso(opts.since));
2121
+ if (opts.until !== void 0) q.set("until", iso(opts.until));
2122
+ if (opts.stepMin !== void 0) q.set("step", String(opts.stepMin));
2123
+ if (opts.host !== void 0) q.set("host", opts.host);
2124
+ return q.size === 0 ? "" : `?${q.toString()}`;
2125
+ }
2023
2126
  var EXEC_GRACE_MS = 6e4;
2024
2127
  var EXEC_WAKE_MS = 5 * 6e4;
2025
2128
  var MAX_EXEC_TIMEOUT_SEC = 86400;
@@ -2034,7 +2137,7 @@ var slugOf2 = (owner) => {
2034
2137
  };
2035
2138
 
2036
2139
  // ../sdk/src/snapshots.ts
2037
- import { z as z5 } from "zod";
2140
+ import { z as z6 } from "zod";
2038
2141
  var Snapshots = class {
2039
2142
  constructor(transport) {
2040
2143
  this.transport = transport;
@@ -2042,19 +2145,19 @@ var Snapshots = class {
2042
2145
  transport;
2043
2146
  /** Every snapshot the caller can read. */
2044
2147
  list(opts = {}) {
2045
- return this.transport.request("GET", `/snapshots${listQuery(opts)}`, z5.array(SnapshotSchema), { org: opts.org });
2148
+ return this.transport.request("GET", `/snapshots${listQuery(opts)}`, z6.array(SnapshotSchema), { org: opts.org });
2046
2149
  }
2047
2150
  /** Snapshot box `req.box` as `req.name` (`replace`: retake one that exists). The box is paused while it is taken. */
2048
2151
  create(req, opts = {}) {
2049
2152
  return this.transport.request("POST", "/snapshots", SnapshotSchema, { body: req, org: opts.org });
2050
2153
  }
2051
2154
  async remove(name, opts = {}) {
2052
- await this.transport.request("DELETE", `/snapshots/${encodeURIComponent(name)}`, z5.undefined(), { org: opts.org });
2155
+ await this.transport.request("DELETE", `/snapshots/${encodeURIComponent(name)}`, z6.undefined(), { org: opts.org });
2053
2156
  }
2054
2157
  };
2055
2158
 
2056
2159
  // ../sdk/src/transport.ts
2057
- import { z as z6 } from "zod";
2160
+ import { z as z7 } from "zod";
2058
2161
  var Transport = class {
2059
2162
  baseUrl;
2060
2163
  org;
@@ -2128,7 +2231,7 @@ var Transport = class {
2128
2231
  }
2129
2232
  }
2130
2233
  };
2131
- var LooseApiErrorSchema = z6.object({ error: z6.string(), code: z6.string().optional() });
2234
+ var LooseApiErrorSchema = z7.object({ error: z7.string(), code: z7.string().optional() });
2132
2235
  function safeJson(text2) {
2133
2236
  try {
2134
2237
  return JSON.parse(text2);
@@ -2146,7 +2249,7 @@ function errorCode(err) {
2146
2249
  }
2147
2250
 
2148
2251
  // ../sdk/src/integrations.ts
2149
- import { z as z7 } from "zod";
2252
+ import { z as z8 } from "zod";
2150
2253
  var Integrations = class {
2151
2254
  constructor(transport) {
2152
2255
  this.transport = transport;
@@ -2154,12 +2257,12 @@ var Integrations = class {
2154
2257
  transport;
2155
2258
  /** Each readable slug's state for each integration (`org`: one org's), connected or not; never a credential. */
2156
2259
  list(opts = {}) {
2157
- return this.transport.request("GET", "/integrations", z7.array(IntegrationSchema), { org: opts.org });
2260
+ return this.transport.request("GET", "/integrations", z8.array(IntegrationSchema), { org: opts.org });
2158
2261
  }
2159
2262
  };
2160
2263
 
2161
2264
  // ../sdk/src/volumes.ts
2162
- import { z as z8 } from "zod";
2265
+ import { z as z9 } from "zod";
2163
2266
  var volume = (name, rest = "") => `/volumes/${encodeURIComponent(name)}${rest}`;
2164
2267
  var Volumes = class {
2165
2268
  constructor(transport) {
@@ -2167,7 +2270,7 @@ var Volumes = class {
2167
2270
  }
2168
2271
  transport;
2169
2272
  list(opts = {}) {
2170
- return this.transport.request("GET", `/volumes${listQuery(opts)}`, z8.array(VolumeSchema), { org: opts.org });
2273
+ return this.transport.request("GET", `/volumes${listQuery(opts)}`, z9.array(VolumeSchema), { org: opts.org });
2171
2274
  }
2172
2275
  /**
2173
2276
  * Make a volume of `sizeGib` GiB. Through the cloud `box` is required: the volume is made on that
@@ -2190,7 +2293,7 @@ var Volumes = class {
2190
2293
  }
2191
2294
  /** Remove the volume and its data; it must be detached first. */
2192
2295
  async remove(name, opts = {}) {
2193
- await this.transport.request("DELETE", volume(name), z8.undefined(), { org: opts.org });
2296
+ await this.transport.request("DELETE", volume(name), z9.undefined(), { org: opts.org });
2194
2297
  }
2195
2298
  };
2196
2299
 
@@ -2240,37 +2343,37 @@ var Kvbox = class {
2240
2343
  };
2241
2344
 
2242
2345
  // src/client.ts
2243
- import { z as z13 } from "zod";
2346
+ import { z as z14 } from "zod";
2244
2347
 
2245
2348
  // ../shared/src/usage.ts
2246
- import { z as z9 } from "zod";
2247
- var PricingSchema = z9.object({
2248
- currency: z9.string().min(1),
2249
- vcpuHour: z9.number().nonnegative(),
2250
- ramGibHour: z9.number().nonnegative(),
2251
- diskGibHour: z9.number().nonnegative(),
2252
- volumeHour: z9.number().nonnegative().default(0),
2253
- volumeGibHour: z9.number().nonnegative().default(0),
2254
- diskIncludedGib: z9.number().int().nonnegative().default(0),
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),
2255
2358
  /**
2256
2359
  * Object storage (#182): an hour of a slug's storage existing, whatever it holds, which covers its
2257
2360
  * hidden box and the first `storageIncludedGib` of its size; each GiB above that is `storageGibHour`.
2258
2361
  * A price list from before object storage charges nothing for it.
2259
2362
  */
2260
- storageHour: z9.number().nonnegative().default(0),
2261
- storageGibHour: z9.number().nonnegative().default(0),
2262
- storageIncludedGib: z9.number().int().nonnegative().default(0),
2363
+ storageHour: z10.number().nonnegative().default(0),
2364
+ storageGibHour: z10.number().nonnegative().default(0),
2365
+ storageIncludedGib: z10.number().int().nonnegative().default(0),
2263
2366
  /** The cron service (#190): an hour of one cron service existing, whatever it holds or fires. A price list from before it charges nothing. */
2264
- cronHour: z9.number().nonnegative().default(0),
2367
+ cronHour: z10.number().nonnegative().default(0),
2265
2368
  /**
2266
2369
  * One backup a person starts, of anything, charged once it is ready (decision "A backup taken by hand
2267
2370
  * costs a flat price…"); a failed one and a scheduled one cost nothing. A price list from before it charges nothing.
2268
2371
  */
2269
- backup: z9.number().nonnegative().default(0)
2372
+ backup: z10.number().nonnegative().default(0)
2270
2373
  });
2271
- var PriceListSchema = PricingSchema.extend({ welcomeCredit: z9.number().nonnegative() });
2374
+ var PriceListSchema = PricingSchema.extend({ welcomeCredit: z10.number().nonnegative() });
2272
2375
  var HOUR_MS = 36e5;
2273
- var round = (n, places) => Math.round(n * 10 ** places) / 10 ** places;
2376
+ var round = (n2, places) => Math.round(n2 * 10 ** places) / 10 ** places;
2274
2377
  function costOf(t, pricing) {
2275
2378
  return t.vcpuHours * pricing.vcpuHour + t.ramGibHours * pricing.ramGibHour + t.diskGibHours * pricing.diskGibHour;
2276
2379
  }
@@ -2296,86 +2399,86 @@ function sumUsage(items, pricing) {
2296
2399
  var DAY_MS = 24 * HOUR_MS;
2297
2400
 
2298
2401
  // ../shared/src/managed.ts
2299
- import { z as z10 } from "zod";
2300
- var PriceSchema = z10.object({ perMonth: z10.number(), storagePerMonth: z10.number(), currency: z10.string() });
2301
- var ManagedCatalogEntrySchema = z10.object({
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({
2302
2405
  /** The kind, as in `/managed/<kind>`: `postgres`. */
2303
- kind: z10.string(),
2406
+ kind: z11.string(),
2304
2407
  /** The CLI command for it: `pg` (`kvbox pg create …`). */
2305
- command: z10.string(),
2306
- title: z10.string(),
2307
- description: z10.string(),
2408
+ command: z11.string(),
2409
+ title: z11.string(),
2410
+ description: z11.string(),
2308
2411
  /** The version a new one runs, as shown: `18`. */
2309
- version: z10.string(),
2412
+ version: z11.string(),
2310
2413
  /** The port a linked box reaches it on. */
2311
- port: z10.number().int(),
2414
+ port: z11.number().int(),
2312
2415
  /** The port `public on` opens behind a host port: `port` again unless the kind serves TLS on another. */
2313
- publicPort: z10.number().int(),
2416
+ publicPort: z11.number().int(),
2314
2417
  /** Its guide, as a URL. */
2315
- docs: z10.string().optional(),
2316
- storage: z10.object({ defaultGib: z10.number().int(), minGib: z10.number().int(), maxGib: z10.number().int() }),
2418
+ docs: z11.string().optional(),
2419
+ storage: z11.object({ defaultGib: z11.number().int(), minGib: z11.number().int(), maxGib: z11.number().int() }),
2317
2420
  /**
2318
2421
  * What create takes of this kind alone, beside what every kind takes (name, password, storage, near): a
2319
2422
  * flag and a form field each, all optional, `default` in words.
2320
2423
  */
2321
- options: z10.array(z10.object({ name: z10.string(), title: z10.string(), description: z10.string(), default: z10.string() })),
2424
+ options: z11.array(z11.object({ name: z11.string(), title: z11.string(), description: z11.string(), default: z11.string() })),
2322
2425
  /** A month of it running with the default storage, and each further GB of storage. */
2323
- price: PriceSchema.extend({ storageGibPerMonth: z10.number() }),
2426
+ price: PriceSchema.extend({ storageGibPerMonth: z11.number() }),
2324
2427
  /** Whether a host answering now can run it. */
2325
- available: z10.boolean()
2428
+ available: z11.boolean()
2326
2429
  });
2327
- var CreateManagedRequest = z10.object({
2328
- name: z10.string(),
2430
+ var CreateManagedRequest = z11.object({
2431
+ name: z11.string(),
2329
2432
  /** The kind's own options by name (its catalog entry lists them); the kind checks them. */
2330
- options: z10.record(z10.string(), z10.string()).optional(),
2331
- password: z10.string().optional(),
2332
- storageGib: z10.number().int().optional(),
2433
+ options: z11.record(z11.string(), z11.string()).optional(),
2434
+ password: z11.string().optional(),
2435
+ storageGib: z11.number().int().optional(),
2333
2436
  /** Place it on the host of this box, so the box can be linked to it. */
2334
- near: z10.string().optional(),
2437
+ near: z11.string().optional(),
2335
2438
  /**
2336
2439
  * A backup of a database of the same kind and major version, of the same account (#186): the new
2337
2440
  * service starts on its data, a removed service's included. Its settings (Postgres: database, user)
2338
2441
  * are the backup's; the password is the new one.
2339
2442
  */
2340
- fromBackup: z10.string().optional()
2443
+ fromBackup: z11.string().optional()
2341
2444
  });
2342
- var ManagedHealthSchema = z10.object({
2445
+ var ManagedHealthSchema = z11.object({
2343
2446
  /** Its first start has finished: it has set itself up on its storage. */
2344
- ready: z10.boolean(),
2447
+ ready: z11.boolean(),
2345
2448
  /** It accepts connections. */
2346
- accepting: z10.boolean(),
2347
- version: z10.string(),
2449
+ accepting: z11.boolean(),
2450
+ version: z11.string(),
2348
2451
  /** The storage volume: what is used of it and its size. */
2349
- storageUsedBytes: z10.number().optional(),
2350
- storageTotalBytes: z10.number().optional(),
2452
+ storageUsedBytes: z11.number().optional(),
2453
+ storageTotalBytes: z11.number().optional(),
2351
2454
  /** What else the kind reports, ready to show: `{title: "Connections", value: "3"}`. */
2352
- facts: z10.array(z10.object({ title: z10.string(), value: z10.string() }))
2455
+ facts: z11.array(z11.object({ title: z11.string(), value: z11.string() }))
2353
2456
  });
2354
- var UrlsSchema = z10.object({ private: z10.string(), public: z10.string().optional() });
2355
- var ManagedSchema = z10.object({
2356
- kind: z10.string(),
2357
- name: z10.string(),
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(),
2358
2461
  /** The owning slug, bare. */
2359
- owner: z10.string(),
2360
- ownerKind: z10.enum(["user", "org"]),
2462
+ owner: z11.string(),
2463
+ ownerKind: z11.enum(["user", "org"]),
2361
2464
  /** `running`, `stopped` (storage only is charged), `hibernated` or `standby` (out of credit), `unknown` (its host does not answer). */
2362
2465
  status: BoxStatusSchema,
2363
2466
  /** The catalog version: `18`. */
2364
- version: z10.string(),
2467
+ version: z11.string(),
2365
2468
  /** What the kind keeps of its create options, defaults filled in: `{database, user}` for Postgres, `{}` for a kind with none. */
2366
- settings: z10.record(z10.string(), z10.string()),
2367
- storageGib: z10.number().int(),
2469
+ settings: z11.record(z11.string(), z11.string()),
2470
+ storageGib: z11.number().int(),
2368
2471
  /** Where a linked box reaches it: `<name>.<slug>.kvbox` (resolves from a box of any slug it is linked to) and the port. */
2369
- private: z10.object({ host: z10.string(), port: z10.number().int() }),
2472
+ private: z11.object({ host: z11.string(), port: z11.number().int() }),
2370
2473
  /** Where the internet reaches it, null while it is not public. The port is its own for its whole life. */
2371
- public: z10.object({ host: z10.string(), port: z10.number().int() }).nullable(),
2474
+ public: z11.object({ host: z11.string(), port: z11.number().int() }).nullable(),
2372
2475
  /** The boxes linked to it, as the caller would name them. */
2373
- links: z10.array(z10.string()),
2476
+ links: z11.array(z11.string()),
2374
2477
  /** The name of the host it runs on, for `--near` and links. */
2375
- host: z10.string(),
2376
- country: z10.string().optional(),
2377
- createdBy: z10.string().nullable(),
2378
- createdAt: z10.string(),
2478
+ host: z11.string(),
2479
+ country: z11.string().optional(),
2480
+ createdBy: z11.string().nullable(),
2481
+ createdAt: z11.string(),
2379
2482
  /** Connection strings with the password as `****`. */
2380
2483
  urls: UrlsSchema,
2381
2484
  price: PriceSchema,
@@ -2384,230 +2487,232 @@ var ManagedSchema = z10.object({
2384
2487
  /** Only in `GET /managed/<kind>/<name>` (asked live): null when it is not running or did not answer. */
2385
2488
  health: ManagedHealthSchema.nullable().optional()
2386
2489
  });
2387
- var ManagedSecretSchema = z10.object({ password: z10.string(), urls: UrlsSchema });
2490
+ var ManagedSecretSchema = z11.object({ password: z11.string(), urls: UrlsSchema });
2388
2491
  var CreatedManagedSchema = ManagedSchema.extend({
2389
2492
  secret: ManagedSecretSchema,
2390
2493
  /** The backup it was made from (`fromBackup`), when it was. */
2391
- fromBackup: z10.string().optional()
2392
- });
2393
- var ResetPasswordRequest = z10.object({ password: z10.string().optional() });
2394
- var SetPublicRequest = z10.object({ on: z10.boolean() });
2395
- var ManagedLinkRequest = z10.object({ box: z10.string() });
2396
- var GrowManagedRequest = z10.object({ storageGib: z10.number().int() });
2397
- var ManagedBackupSchema = z10.object({
2398
- id: z10.string(),
2399
- owner: z10.string(),
2400
- kind: z10.string(),
2401
- name: z10.string(),
2402
- version: z10.string(),
2403
- status: z10.enum(BACKUP_STATUSES),
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),
2404
2507
  /** Why it failed; null otherwise. */
2405
- error: z10.string().nullable(),
2508
+ error: z11.string().nullable(),
2406
2509
  /** The service's storage when taken. */
2407
- diskBytes: z10.number().int().nullable(),
2510
+ diskBytes: z11.number().int().nullable(),
2408
2511
  /** What it holds: the slots that are not all zeros. */
2409
- dataBytes: z10.number().int().nullable(),
2512
+ dataBytes: z11.number().int().nullable(),
2410
2513
  /** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
2411
- uploadedBytes: z10.number().int().nullable(),
2514
+ uploadedBytes: z11.number().int().nullable(),
2412
2515
  /** Who asked for it; for a scheduled one, the database's creator. */
2413
- createdBy: z10.string().nullable(),
2516
+ createdBy: z11.string().nullable(),
2414
2517
  /** Started by the database's backup schedule, not by a person: it does not count toward the daily limit. */
2415
- scheduled: z10.boolean().default(false),
2416
- createdAt: z10.string(),
2417
- finishedAt: z10.string().nullable()
2518
+ scheduled: z11.boolean().default(false),
2519
+ createdAt: z11.string(),
2520
+ finishedAt: z11.string().nullable()
2418
2521
  });
2419
2522
 
2420
2523
  // ../shared/src/cron.ts
2421
- import { z as z11 } from "zod";
2524
+ import { z as z12 } from "zod";
2422
2525
  var DEFAULT_CRON_COMMAND_TIMEOUT_SEC = 600;
2423
2526
  var MAX_CRON_COMMAND_TIMEOUT_SEC = 3600;
2424
2527
  var CRON_RUN_LOG_DIR = "/var/log/kvbox/runs";
2425
2528
  var CRON_METHODS = ["GET", "POST"];
2426
2529
  var CRON_OUTCOMES = ["running", "ok", "failed", "timeout", "no-credit", "box-stopped", "host-down", "host-outdated", "lost", "still-running", "box-outdated"];
2427
- var CronServiceSchema = z11.object({
2428
- owner: z11.string(),
2429
- ownerKind: z11.enum(["user", "org"]),
2430
- name: z11.string(),
2530
+ var CronServiceSchema = z12.object({
2531
+ owner: z12.string(),
2532
+ ownerKind: z12.enum(["user", "org"]),
2533
+ name: z12.string(),
2431
2534
  /** Runs kept per trigger. */
2432
- keepRuns: z11.number().int(),
2433
- triggers: z11.number().int(),
2434
- createdBy: z11.string().nullable(),
2435
- createdAt: z11.string(),
2535
+ keepRuns: z12.number().int(),
2536
+ triggers: z12.number().int(),
2537
+ createdBy: z12.string().nullable(),
2538
+ createdAt: z12.string(),
2436
2539
  /** What it costs while it exists; on the answer to `POST /cron` only. */
2437
- price: z11.object({ perMonth: z11.number(), currency: z11.string() }).optional()
2540
+ price: z12.object({ perMonth: z12.number(), currency: z12.string() }).optional()
2438
2541
  });
2439
2542
  var triggerCommon = {
2440
- id: z11.string(),
2441
- service: z11.string(),
2442
- owner: z11.string(),
2543
+ id: z12.string(),
2544
+ service: z12.string(),
2545
+ owner: z12.string(),
2443
2546
  /** The box it acts on; a trigger is removed with its box. */
2444
- box: z11.string(),
2547
+ box: z12.string(),
2445
2548
  /** Five fields, `minute hour day-of-month month day-of-week`. */
2446
- expr: z11.string(),
2549
+ expr: z12.string(),
2447
2550
  /** An IANA zone (`Europe/Bucharest`) the expression is read in; `UTC` unless said. */
2448
- timezone: z11.string(),
2551
+ timezone: z12.string(),
2449
2552
  /** False: paused, it fires again when resumed. */
2450
- enabled: z11.boolean(),
2553
+ enabled: z12.boolean(),
2451
2554
  /** When it fires next (ISO); null while paused. */
2452
- nextRunAt: z11.string().nullable(),
2453
- lastRunAt: z11.string().nullable(),
2454
- lastOutcome: z11.enum(CRON_OUTCOMES).nullable(),
2455
- createdBy: z11.string().nullable(),
2456
- createdAt: z11.string()
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()
2457
2560
  };
2458
- var CronHttpTriggerSchema = z11.object({
2561
+ var CronHttpTriggerSchema = z12.object({
2459
2562
  ...triggerCommon,
2460
- kind: z11.literal("http"),
2461
- method: z11.enum(CRON_METHODS),
2462
- port: z11.number().int(),
2563
+ kind: z12.literal("http"),
2564
+ method: z12.enum(CRON_METHODS),
2565
+ port: z12.number().int(),
2463
2566
  /** Path and query, starting with `/`. */
2464
- path: z11.string()
2567
+ path: z12.string()
2465
2568
  });
2466
- var CronCommandTriggerSchema = z11.object({
2569
+ var CronCommandTriggerSchema = z12.object({
2467
2570
  ...triggerCommon,
2468
- kind: z11.literal("command"),
2571
+ kind: z12.literal("command"),
2469
2572
  /** Run by a login shell as the box's user, in its home. */
2470
- command: z11.string(),
2573
+ command: z12.string(),
2471
2574
  /** The command is stopped after this long. */
2472
- timeoutSec: z11.number().int()
2575
+ timeoutSec: z12.number().int()
2473
2576
  });
2474
- var CronTriggerSchema = z11.discriminatedUnion("kind", [CronHttpTriggerSchema, CronCommandTriggerSchema]);
2475
- var CronRunSchema = z11.object({
2577
+ var CronTriggerSchema = z12.discriminatedUnion("kind", [CronHttpTriggerSchema, CronCommandTriggerSchema]);
2578
+ var CronRunSchema = z12.object({
2476
2579
  /** The slot this run was for (ISO); a run asked for by hand has the moment it was asked. */
2477
- scheduledFor: z11.string(),
2478
- startedAt: z11.string(),
2580
+ scheduledFor: z12.string(),
2581
+ startedAt: z12.string(),
2479
2582
  /** Null while `running`, and for a run that was never sent. */
2480
- durationMs: z11.number().int().nullable(),
2583
+ durationMs: z12.number().int().nullable(),
2481
2584
  /** The box's HTTP status; null when it never answered, and for a command. */
2482
- status: z11.number().int().nullable(),
2585
+ status: z12.number().int().nullable(),
2483
2586
  /** A command's exit code (128 + the signal when one ended it); null until it ends, and for a request. */
2484
- exitCode: z11.number().int().nullable(),
2587
+ exitCode: z12.number().int().nullable(),
2485
2588
  /** 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. */
2486
- output: z11.string().nullable(),
2487
- outcome: z11.enum(CRON_OUTCOMES),
2589
+ output: z12.string().nullable(),
2590
+ outcome: z12.enum(CRON_OUTCOMES),
2488
2591
  /** Why it did not end `ok`, in a line. */
2489
- error: z11.string().nullable(),
2592
+ error: z12.string().nullable(),
2490
2593
  /** The box was hibernated and this run woke it. */
2491
- woke: z11.boolean()
2594
+ woke: z12.boolean()
2492
2595
  });
2493
- var CronCatalogSchema = z11.object({
2494
- price: z11.object({ perMonth: z11.number(), currency: z11.string() }),
2495
- maxServices: z11.number().int(),
2496
- maxTriggers: z11.number().int(),
2497
- keepRuns: z11.number().int(),
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(),
2498
2601
  /** The shortest time between two runs of one trigger, in seconds. */
2499
- minIntervalSeconds: z11.number().int(),
2602
+ minIntervalSeconds: z12.number().int(),
2500
2603
  /** How long a box has to answer, in seconds. */
2501
- timeoutSeconds: z11.number().int(),
2604
+ timeoutSeconds: z12.number().int(),
2502
2605
  /** How long a command may run: unless the trigger says, and at most. */
2503
- commandTimeoutSeconds: z11.number().int(),
2504
- maxCommandTimeoutSeconds: z11.number().int(),
2505
- docs: z11.string().optional()
2506
- });
2507
- var CreateCronServiceRequest = z11.object({ name: z11.string() });
2508
- var CreateCronTriggerRequest = z11.object({
2509
- box: z11.string().min(1),
2510
- expr: z11.string().min(1),
2511
- timezone: z11.string().optional(),
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(),
2512
2615
  /** A request: `port`, with `method` and `path`. */
2513
- method: z11.enum(CRON_METHODS).optional(),
2514
- port: z11.number().int().min(1).max(65535).optional(),
2515
- path: z11.string().optional(),
2616
+ method: z12.enum(CRON_METHODS).optional(),
2617
+ port: z12.number().int().min(1).max(65535).optional(),
2618
+ path: z12.string().optional(),
2516
2619
  /** Or a command, with `timeoutSec`; exactly one of `port` and `command`. */
2517
- command: z11.string().optional(),
2518
- timeoutSec: z11.number().int().optional()
2620
+ command: z12.string().optional(),
2621
+ timeoutSec: z12.number().int().optional()
2519
2622
  });
2520
- var UpdateCronTriggerRequest = z11.object({ enabled: z11.boolean() });
2623
+ var UpdateCronTriggerRequest = z12.object({ enabled: z12.boolean() });
2521
2624
  var cronTarget = (t) => t.kind === "command" ? `${t.box}$ ${t.command}` : `${t.method} ${t.box}:${t.port}${t.path}`;
2522
2625
 
2523
2626
  // ../shared/src/storage.ts
2524
- import { z as z12 } from "zod";
2525
- var RegionSchema = z12.object({ name: z12.string(), country: z12.string().nullable() });
2627
+ import { z as z13 } from "zod";
2628
+ var RegionSchema = z13.object({ name: z13.string(), country: z13.string().nullable() });
2526
2629
  var MAX_PUBLIC_BUCKETS = 10;
2527
2630
  var STORAGE_BOX_SUBDOMAINS = MAX_PUBLIC_BUCKETS + 2;
2528
- var ObjectStorageSchema = z12.object({
2529
- owner: z12.string(),
2530
- ownerKind: z12.enum(["user", "org"]),
2631
+ var ObjectStorageSchema = z13.object({
2632
+ owner: z13.string(),
2633
+ ownerKind: z13.enum(["user", "org"]),
2531
2634
  /** `https://s3-<slug>.<domain>`: what an S3 client is given, with path-style addressing. Null while the address is not claimed. */
2532
- endpoint: z12.string().nullable(),
2635
+ endpoint: z13.string().nullable(),
2533
2636
  /** The S3 region every client of it signs with (`ro-west-1`): its host's when it was made. */
2534
- region: z12.string(),
2637
+ region: z13.string(),
2535
2638
  /** The most it may hold. */
2536
- sizeGib: z12.number().int(),
2639
+ sizeGib: z13.number().int(),
2537
2640
  /** `running` when it answers; `unknown` while its host is not heard from. */
2538
2641
  status: BoxStatusSchema,
2539
2642
  /** With `?live=1`, when the storage answered: what is on its disk, and the disk's real size. */
2540
- usedBytes: z12.number().optional(),
2541
- totalBytes: z12.number().optional(),
2643
+ usedBytes: z13.number().optional(),
2644
+ totalBytes: z13.number().optional(),
2542
2645
  /** With `?live=1`, when the storage answered: what each bucket holds. */
2543
- bucketUsage: z12.array(z12.object({ name: z12.string(), objects: z12.number(), bytes: z12.number() })).optional(),
2544
- host: z12.string(),
2545
- country: z12.string().optional(),
2546
- buckets: z12.number().int(),
2547
- price: z12.object({ perMonth: z12.number(), currency: z12.string() }),
2548
- createdAt: z12.string()
2549
- });
2550
- var BucketSchema = z12.object({
2551
- name: z12.string(),
2552
- owner: z12.string(),
2553
- ownerKind: z12.enum(["user", "org"]),
2554
- endpoint: z12.string().nullable(),
2555
- publicUrl: z12.string().optional(),
2556
- region: z12.string(),
2557
- keys: z12.number().int(),
2558
- objects: z12.number().optional(),
2559
- bytes: z12.number().optional(),
2560
- createdBy: z12.string().nullable(),
2561
- createdAt: z12.string()
2562
- });
2563
- var CreateBucketRequest = z12.object({
2564
- name: z12.string(),
2565
- sizeGib: z12.number().int().optional(),
2566
- near: z12.string().optional(),
2567
- region: z12.string().optional()
2568
- });
2569
- var CreatedBucketSchema = BucketSchema.extend({ storage: ObjectStorageSchema, storageCreated: z12.boolean() });
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() });
2570
2673
  var BucketInfoSchema = BucketSchema.extend({ storage: ObjectStorageSchema });
2571
- var SetBucketPublicRequest = z12.object({ on: z12.boolean(), sub: z12.string().optional() });
2572
- var BucketKeySchema = z12.object({
2573
- id: z12.string(),
2574
- name: z12.string(),
2575
- bucket: z12.string(),
2576
- owner: z12.string(),
2577
- readOnly: z12.boolean(),
2578
- createdBy: z12.string().nullable(),
2579
- createdAt: z12.string()
2580
- });
2581
- var CreateBucketKeyRequest = z12.object({ name: z12.string().optional(), readOnly: z12.boolean().optional() });
2582
- var CreatedBucketKeySchema = BucketKeySchema.extend({ secret: z12.string(), endpoint: z12.string().nullable(), region: z12.string() });
2583
- var GrowStorageRequest = z12.object({ sizeGib: z12.number().int() });
2584
- var StorageBackupSchema = z12.object({
2585
- id: z12.string(),
2586
- owner: z12.string(),
2587
- status: z12.enum(BACKUP_STATUSES),
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),
2588
2691
  /** Why it failed; null otherwise. */
2589
- error: z12.string().nullable(),
2692
+ error: z13.string().nullable(),
2590
2693
  /** The storage's volume when taken. */
2591
- diskBytes: z12.number().int().nullable(),
2694
+ diskBytes: z13.number().int().nullable(),
2592
2695
  /** What it holds: the slots that are not all zeros. */
2593
- dataBytes: z12.number().int().nullable(),
2696
+ dataBytes: z13.number().int().nullable(),
2594
2697
  /** What this backup added to the backup store (encrypted, compressed). */
2595
- uploadedBytes: z12.number().int().nullable(),
2698
+ uploadedBytes: z13.number().int().nullable(),
2596
2699
  /** The buckets it holds, and how many access keys they had, as kvbox knew them when it was taken. */
2597
- buckets: z12.array(z12.string()),
2598
- keys: z12.number().int(),
2599
- createdBy: z12.string().nullable(),
2600
- createdAt: z12.string(),
2601
- finishedAt: z12.string().nullable()
2602
- });
2603
- var RestoredKeySchema = z12.object({ bucket: z12.string(), id: z12.string(), name: z12.string() });
2604
- var StorageRestoreSchema = z12.object({
2605
- backup: z12.string(),
2700
+ buckets: z13.array(z13.string()),
2701
+ keys: z13.number().int(),
2702
+ createdBy: z13.string().nullable(),
2703
+ /** 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()
2707
+ });
2708
+ var RestoredKeySchema = z13.object({ bucket: z13.string(), id: z13.string(), name: z13.string() });
2709
+ var StorageRestoreSchema = z13.object({
2710
+ backup: z13.string(),
2606
2711
  storage: ObjectStorageSchema,
2607
- buckets: z12.object({ kept: z12.array(z12.string()), returned: z12.array(z12.string()), removed: z12.array(z12.string()) }),
2608
- keys: z12.object({ dropped: z12.array(RestoredKeySchema), revoked: z12.array(RestoredKeySchema) }),
2609
- checked: z12.boolean(),
2610
- warnings: z12.array(z12.string())
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())
2611
2716
  });
2612
2717
  var OBJECT_LIST_MAX = 1e3;
2613
2718
  var SHARE_LINK_MAX_SEC = 7 * 24 * 3600;
@@ -2617,56 +2722,56 @@ var MULTIPART_PART_BYTES = 16 * 1024 * 1024;
2617
2722
  var UPLOAD_MAX_BYTES = 50 * 1024 * 1024 * 1024;
2618
2723
  var MOVE_MAX_BYTES = 5 * 1024 * 1024 * 1024;
2619
2724
  var DELETE_PREFIXES_MAX = 100;
2620
- var StoredObjectSchema = z12.object({
2621
- key: z12.string(),
2622
- size: z12.number(),
2623
- etag: z12.string(),
2725
+ var StoredObjectSchema = z13.object({
2726
+ key: z13.string(),
2727
+ size: z13.number(),
2728
+ etag: z13.string(),
2624
2729
  /** ISO 8601. */
2625
- modified: z12.string()
2626
- });
2627
- var ObjectListingSchema = z12.object({
2628
- prefix: z12.string(),
2629
- folders: z12.array(z12.string()),
2630
- objects: z12.array(StoredObjectSchema),
2631
- next: z12.string().optional(),
2632
- canWrite: z12.boolean()
2633
- });
2634
- var ObjectInfoSchema = StoredObjectSchema.extend({ contentType: z12.string() });
2635
- var ObjectCountSchema = z12.object({ objects: z12.number(), bytes: z12.number(), more: z12.boolean() });
2636
- var ObjectLinkRequest = z12.object({
2637
- key: z12.string(),
2638
- expiresSec: z12.number().int().positive(),
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(),
2639
2744
  /** Answer as a download (`Content-Disposition: attachment`) instead of showing it. */
2640
- download: z12.boolean().optional(),
2745
+ download: z13.boolean().optional(),
2641
2746
  /**
2642
2747
  * Let the browser keep what the link answers until the link expires (`Cache-Control: private`, `Expires`),
2643
2748
  * so the same link shown twice is fetched once. Asked again within the hour, for the same file as it
2644
2749
  * is, it is the same URL, and it lasts up to an hour longer than `expiresSec`. For the app's own previews.
2645
2750
  * Only a fetch of the whole file is kept so: the storage answers a part of one (`Range`) without the two headers.
2646
2751
  */
2647
- cached: z12.boolean().optional()
2752
+ cached: z13.boolean().optional()
2648
2753
  });
2649
- var ObjectLinkSchema = z12.object({ url: z12.string(), expiresAt: z12.string() });
2754
+ var ObjectLinkSchema = z13.object({ url: z13.string(), expiresAt: z13.string() });
2650
2755
  var MEDIA_TYPE_RE = /^[\w.+-]+\/[\w.+-]+(?:\s*;[\x20-\x7e]*)?$/;
2651
- var StartUploadRequest = z12.object({ key: z12.string(), size: z12.number().int().nonnegative(), contentType: z12.string().max(200).regex(MEDIA_TYPE_RE, "not a media type like image/png").optional(), overwrite: z12.boolean().optional() });
2652
- var UploadPlanSchema = z12.discriminatedUnion("kind", [
2653
- z12.object({ kind: z12.literal("single"), url: z12.string() }),
2654
- z12.object({ kind: z12.literal("multipart"), uploadId: z12.string(), partSize: z12.number(), urls: z12.array(z12.string()) })
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()) })
2655
2760
  ]);
2656
- var CompleteUploadRequest = z12.object({
2657
- key: z12.string(),
2658
- uploadId: z12.string(),
2659
- parts: z12.array(z12.object({ part: z12.number().int().positive(), etag: z12.string() })).min(1)
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)
2660
2765
  });
2661
- var AbortUploadRequest = z12.object({ key: z12.string(), uploadId: z12.string() });
2662
- var DeleteObjectsRequest = z12.object({ keys: z12.array(z12.string()).max(OBJECT_LIST_MAX).optional(), prefixes: z12.array(z12.string()).max(DELETE_PREFIXES_MAX).optional() });
2663
- var DeletedObjectsSchema = z12.object({
2664
- deleted: z12.number(),
2665
- more: z12.boolean(),
2666
- errors: z12.array(z12.object({ key: z12.string(), message: z12.string() }))
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() }))
2667
2772
  });
2668
- var MoveObjectRequest = z12.object({ from: z12.string(), to: z12.string(), overwrite: z12.boolean().optional() });
2669
- var CreateFolderRequest = z12.object({ prefix: z12.string() });
2773
+ var MoveObjectRequest = z13.object({ from: z13.string(), to: z13.string(), overwrite: z13.boolean().optional() });
2774
+ var CreateFolderRequest = z13.object({ prefix: z13.string() });
2670
2775
 
2671
2776
  // src/kvm.ts
2672
2777
  import { accessSync, constants, readFileSync, statSync } from "fs";
@@ -2836,7 +2941,7 @@ var ServerClient = class {
2836
2941
  * `all`: every box on the platform (platform admins only, #78).
2837
2942
  */
2838
2943
  listMachines(opts = {}) {
2839
- return this.call("GET", `/machines${allQuery(opts)}`, z13.array(MachineSchema), void 0, opts.org);
2944
+ return this.call("GET", `/machines${allQuery(opts)}`, z14.array(MachineSchema), void 0, opts.org);
2840
2945
  }
2841
2946
  createMachine(req) {
2842
2947
  return this.call("POST", "/machines", MachineSchema, req, void 0, req.fromBackup !== void 0 ? 2 * 36e5 : void 0);
@@ -2890,14 +2995,22 @@ var ServerClient = class {
2890
2995
  }
2891
2996
  /** Backups, the control plane's only: a box's disk in object storage. Newest first. */
2892
2997
  listBackups() {
2893
- return this.call("GET", "/backups", z13.array(BackupSchema));
2998
+ return this.call("GET", "/backups", z14.array(BackupSchema));
2894
2999
  }
2895
3000
  boxBackups(name) {
2896
- return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z13.array(BackupSchema));
3001
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z14.array(BackupSchema));
2897
3002
  }
2898
3003
  boxBackup(name, id) {
2899
3004
  return this.call("GET", `/machines/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, BackupSchema);
2900
3005
  }
3006
+ /** A box's nightly backup: off, with no row, until it is turned on. */
3007
+ boxBackupSchedule(name) {
3008
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/backup-schedule`, BackupScheduleSchema);
3009
+ }
3010
+ /** On or off, or another hour (UTC, which turns it on). */
3011
+ setBoxBackupSchedule(name, change) {
3012
+ return this.call("PUT", `/machines/${encodeURIComponent(name)}/backup-schedule`, BackupScheduleSchema, change);
3013
+ }
2901
3014
  /** Starts one; it runs in the background (`running`), `boxBackup` says how it ended. */
2902
3015
  createBoxBackup(name) {
2903
3016
  return this.call("POST", `/machines/${encodeURIComponent(name)}/backups`, BackupSchema);
@@ -2907,18 +3020,25 @@ var ServerClient = class {
2907
3020
  * later. Works for a backup whose box, volume or database is gone too.
2908
3021
  */
2909
3022
  removeBackup(id) {
2910
- return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z13.undefined());
3023
+ return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z14.undefined());
2911
3024
  }
2912
3025
  /** A volume's backups (#168): the same as a box's, of the volume's disk. Newest first. */
2913
3026
  listVolumeBackups() {
2914
- return this.call("GET", "/backups?kind=volume", z13.array(VolumeBackupSchema));
3027
+ return this.call("GET", "/backups?kind=volume", z14.array(VolumeBackupSchema));
2915
3028
  }
2916
3029
  volumeBackups(name) {
2917
- return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z13.array(VolumeBackupSchema));
3030
+ return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z14.array(VolumeBackupSchema));
2918
3031
  }
2919
3032
  volumeBackup(name, id) {
2920
3033
  return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, VolumeBackupSchema);
2921
3034
  }
3035
+ /** A volume's nightly backup: off, with no row, until it is turned on. */
3036
+ volumeBackupSchedule(name) {
3037
+ return this.call("GET", `/volumes/${encodeURIComponent(name)}/backup-schedule`, BackupScheduleSchema);
3038
+ }
3039
+ setVolumeBackupSchedule(name, change) {
3040
+ return this.call("PUT", `/volumes/${encodeURIComponent(name)}/backup-schedule`, BackupScheduleSchema, change);
3041
+ }
2922
3042
  /** Starts one; it runs in the background (`running`), `volumeBackup` says how it ended. */
2923
3043
  createVolumeBackup(name) {
2924
3044
  return this.call("POST", `/volumes/${encodeURIComponent(name)}/backups`, VolumeBackupSchema);
@@ -2933,7 +3053,7 @@ var ServerClient = class {
2933
3053
  }
2934
3054
  /** Wake hooks (#101), the control plane's only: a URL and a secret that wake the box. */
2935
3055
  boxHooks(name) {
2936
- return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z13.array(WakeHookSchema));
3056
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z14.array(WakeHookSchema));
2937
3057
  }
2938
3058
  createBoxHook(name) {
2939
3059
  return this.call("POST", `/machines/${encodeURIComponent(name)}/hooks`, CreatedWakeHookSchema);
@@ -2961,7 +3081,7 @@ var ServerClient = class {
2961
3081
  }
2962
3082
  /** Every readable box's subdomains, one entry each. */
2963
3083
  listSubdomains() {
2964
- return this.call("GET", "/subdomains", z13.array(SubdomainSchema));
3084
+ return this.call("GET", "/subdomains", z14.array(SubdomainSchema));
2965
3085
  }
2966
3086
  /** Custom domains (#89), the control plane's only: serve the box at the user's own name. */
2967
3087
  addDomain(name, req) {
@@ -2972,7 +3092,7 @@ var ServerClient = class {
2972
3092
  }
2973
3093
  /** Every readable box's custom domains. */
2974
3094
  listDomains() {
2975
- return this.call("GET", "/domains", z13.array(DomainSchema));
3095
+ return this.call("GET", "/domains", z14.array(DomainSchema));
2976
3096
  }
2977
3097
  /** A running box's own load, memory and disk, asked of its guest (#67). */
2978
3098
  machineStats(name) {
@@ -2983,6 +3103,10 @@ var ServerClient = class {
2983
3103
  const query = since === void 0 ? "" : `?since=${encodeURIComponent(since)}`;
2984
3104
  return this.call("GET", `/machines/${encodeURIComponent(name)}/usage${query}`, MachineUsageSchema);
2985
3105
  }
3106
+ /** A box's traffic through its HTTPS names (#206); a control plane only. `query`: "" or "?since=…&host=…". */
3107
+ machineTraffic(name, query) {
3108
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/traffic${query}`, TrafficReportSchema);
3109
+ }
2986
3110
  /** Every box of the caller over the window (#41 on a host, #42 through a control plane); dates as the user wrote them. */
2987
3111
  usageReport(since, until2, all = false) {
2988
3112
  const q = new URLSearchParams();
@@ -3005,22 +3129,22 @@ var ServerClient = class {
3005
3129
  return this.call("POST", "/billing/redeem", RedeemResponseSchema, { code });
3006
3130
  }
3007
3131
  deleteMachine(name) {
3008
- return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z13.undefined());
3132
+ return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z14.undefined());
3009
3133
  }
3010
3134
  /** Like `listMachines`, for snapshots. */
3011
3135
  listSnapshots(opts = {}) {
3012
- return this.call("GET", `/snapshots${allQuery(opts)}`, z13.array(SnapshotSchema), void 0, opts.org);
3136
+ return this.call("GET", `/snapshots${allQuery(opts)}`, z14.array(SnapshotSchema), void 0, opts.org);
3013
3137
  }
3014
3138
  createSnapshot(req) {
3015
3139
  return this.call("POST", "/snapshots", SnapshotSchema, req);
3016
3140
  }
3017
3141
  deleteSnapshot(name) {
3018
- return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z13.undefined());
3142
+ return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z14.undefined());
3019
3143
  }
3020
3144
  // ---- environment variables (#88), a control plane only: the caller's slug, or `--org`'s ----
3021
3145
  /** `org`: that org's list instead of `--org`'s (or the caller's own). */
3022
3146
  listEnv(org) {
3023
- return this.call("GET", "/vars", z13.array(EnvVarSchema), void 0, org);
3147
+ return this.call("GET", "/vars", z14.array(EnvVarSchema), void 0, org);
3024
3148
  }
3025
3149
  setEnv(name, req) {
3026
3150
  return this.call("PUT", `/vars/${encodeURIComponent(name)}`, EnvChangeSchema, req);
@@ -3040,13 +3164,13 @@ var ServerClient = class {
3040
3164
  }
3041
3165
  // ---- volumes (#52) ----
3042
3166
  listVolumes(opts = {}) {
3043
- return this.call("GET", `/volumes${allQuery(opts)}`, z13.array(VolumeSchema), void 0, opts.org);
3167
+ return this.call("GET", `/volumes${allQuery(opts)}`, z14.array(VolumeSchema), void 0, opts.org);
3044
3168
  }
3045
3169
  createVolume(req) {
3046
3170
  return this.call("POST", "/volumes", VolumeSchema, req);
3047
3171
  }
3048
3172
  deleteVolume(name) {
3049
- return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z13.undefined());
3173
+ return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z14.undefined());
3050
3174
  }
3051
3175
  /** Both answer with the box as it is afterwards (restarted when it was running). */
3052
3176
  attachVolume(name, req) {
@@ -3061,7 +3185,7 @@ var ServerClient = class {
3061
3185
  }
3062
3186
  // ---- cron service (#190): the control plane's alone ----
3063
3187
  listCronServices(opts = {}) {
3064
- return this.call("GET", `/cron${allQuery(opts)}`, z13.array(CronServiceSchema), void 0, opts.org);
3188
+ return this.call("GET", `/cron${allQuery(opts)}`, z14.array(CronServiceSchema), void 0, opts.org);
3065
3189
  }
3066
3190
  createCronService(name) {
3067
3191
  return this.call("POST", "/cron", CronServiceSchema, { name });
@@ -3070,10 +3194,10 @@ var ServerClient = class {
3070
3194
  return this.call("GET", `/cron/${encodeURIComponent(name)}`, CronServiceSchema);
3071
3195
  }
3072
3196
  deleteCronService(name) {
3073
- return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z13.undefined());
3197
+ return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z14.undefined());
3074
3198
  }
3075
3199
  listCronTriggers(service) {
3076
- return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z13.array(CronTriggerSchema));
3200
+ return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z14.array(CronTriggerSchema));
3077
3201
  }
3078
3202
  addCronTrigger(service, req) {
3079
3203
  return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers`, CronTriggerSchema, req);
@@ -3083,18 +3207,18 @@ var ServerClient = class {
3083
3207
  return this.call("PATCH", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, CronTriggerSchema, { enabled: enabled2 });
3084
3208
  }
3085
3209
  deleteCronTrigger(service, id) {
3086
- return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, z13.undefined());
3210
+ return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, z14.undefined());
3087
3211
  }
3088
3212
  /** Marks it due: kvbox-cron fires it within a few seconds. */
3089
3213
  runCronTrigger(service, id) {
3090
3214
  return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/run`, CronTriggerSchema);
3091
3215
  }
3092
3216
  listCronRuns(service, id, limit) {
3093
- return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`, z13.array(CronRunSchema));
3217
+ return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`, z14.array(CronRunSchema));
3094
3218
  }
3095
3219
  // ---- object storage (#182): the control plane's alone ----
3096
3220
  listBuckets(opts = {}) {
3097
- return this.call("GET", `/buckets${allQuery(opts)}`, z13.array(BucketSchema), void 0, opts.org);
3221
+ return this.call("GET", `/buckets${allQuery(opts)}`, z14.array(BucketSchema), void 0, opts.org);
3098
3222
  }
3099
3223
  /** The first bucket of a slug also makes its storage: a box boots twice, so this may take a couple of minutes. */
3100
3224
  createBucket(req) {
@@ -3108,30 +3232,37 @@ var ServerClient = class {
3108
3232
  return this.call("PUT", `/buckets/${encodeURIComponent(name)}/public`, BucketSchema, req);
3109
3233
  }
3110
3234
  deleteBucket(name, force = false) {
3111
- return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`, z13.undefined());
3235
+ return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`, z14.undefined());
3112
3236
  }
3113
3237
  listBucketKeys(name) {
3114
- return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z13.array(BucketKeySchema));
3238
+ return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z14.array(BucketKeySchema));
3115
3239
  }
3116
3240
  createBucketKey(name, req) {
3117
3241
  return this.call("POST", `/buckets/${encodeURIComponent(name)}/keys`, CreatedBucketKeySchema, req);
3118
3242
  }
3119
3243
  deleteBucketKey(name, id) {
3120
- return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`, z13.undefined());
3244
+ return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`, z14.undefined());
3121
3245
  }
3122
3246
  listStorage(opts = {}) {
3123
- return this.call("GET", `/storage${allQuery(opts)}`, z13.array(ObjectStorageSchema), void 0, opts.org);
3247
+ return this.call("GET", `/storage${allQuery(opts)}`, z14.array(ObjectStorageSchema), void 0, opts.org);
3124
3248
  }
3125
3249
  growStorage(sizeGib) {
3126
3250
  return this.call("POST", "/storage/grow", ObjectStorageSchema, { sizeGib });
3127
3251
  }
3128
3252
  /** Backups of the slug's whole object storage (#186 slice 3), newest first. */
3129
3253
  storageBackups() {
3130
- return this.call("GET", "/storage/backups", z13.array(StorageBackupSchema));
3254
+ return this.call("GET", "/storage/backups", z14.array(StorageBackupSchema));
3131
3255
  }
3132
3256
  storageBackup(id) {
3133
3257
  return this.call("GET", `/storage/backups/${encodeURIComponent(id)}`, StorageBackupSchema);
3134
3258
  }
3259
+ /** The nightly backup of the slug's object storage: off until it is turned on. */
3260
+ storageBackupSchedule() {
3261
+ return this.call("GET", "/storage/backup-schedule", BackupScheduleSchema);
3262
+ }
3263
+ setStorageBackupSchedule(change) {
3264
+ return this.call("PUT", "/storage/backup-schedule", BackupScheduleSchema, change);
3265
+ }
3135
3266
  /** Starts one; it runs in the background (`running`), `storageBackup` says how it ended. */
3136
3267
  createStorageBackup() {
3137
3268
  return this.call("POST", "/storage/backups", StorageBackupSchema);
@@ -3148,11 +3279,11 @@ var ServerClient = class {
3148
3279
  return `/managed/${encodeURIComponent(kind)}${name === void 0 ? "" : `/${encodeURIComponent(name)}`}${rest}`;
3149
3280
  }
3150
3281
  managedCatalog() {
3151
- return this.call("GET", "/managed/catalog", z13.array(ManagedCatalogEntrySchema));
3282
+ return this.call("GET", "/managed/catalog", z14.array(ManagedCatalogEntrySchema));
3152
3283
  }
3153
3284
  /** One kind's services, or every kind's when `kind` is left out. */
3154
3285
  listManaged(kind, opts = {}) {
3155
- return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`, z13.array(ManagedSchema), void 0, opts.org);
3286
+ return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`, z14.array(ManagedSchema), void 0, opts.org);
3156
3287
  }
3157
3288
  /** From a backup (`fromBackup`) it waits for the restore too: the control plane gives its host 2 h for the download. */
3158
3289
  createManaged(kind, req) {
@@ -3163,7 +3294,7 @@ var ServerClient = class {
3163
3294
  return this.call("GET", this.managedPath(kind, name), ManagedSchema);
3164
3295
  }
3165
3296
  deleteManaged(kind, name) {
3166
- return this.call("DELETE", this.managedPath(kind, name), z13.undefined());
3297
+ return this.call("DELETE", this.managedPath(kind, name), z14.undefined());
3167
3298
  }
3168
3299
  managedPassword(kind, name) {
3169
3300
  return this.call("GET", this.managedPath(kind, name, "/password"), ManagedSecretSchema);
@@ -3185,10 +3316,10 @@ var ServerClient = class {
3185
3316
  }
3186
3317
  /** A managed service's backups (#186): its storage's, by the volume backup engine. Every one of a kind, those of removed services too. */
3187
3318
  listManagedBackups(kind) {
3188
- return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z13.array(ManagedBackupSchema));
3319
+ return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z14.array(ManagedBackupSchema));
3189
3320
  }
3190
3321
  managedBackups(kind, name) {
3191
- return this.call("GET", this.managedPath(kind, name, "/backups"), z13.array(ManagedBackupSchema));
3322
+ return this.call("GET", this.managedPath(kind, name, "/backups"), z14.array(ManagedBackupSchema));
3192
3323
  }
3193
3324
  managedBackup(kind, name, id) {
3194
3325
  return this.call("GET", this.managedPath(kind, name, `/backups/${encodeURIComponent(id)}`), ManagedBackupSchema);
@@ -3230,7 +3361,7 @@ var ServerClient = class {
3230
3361
  return this.call("POST", "/login/device/token", DeviceLoginPollSchema, { deviceCode });
3231
3362
  }
3232
3363
  logout() {
3233
- return this.call("POST", "/logout", z13.unknown()).then(() => void 0);
3364
+ return this.call("POST", "/logout", z14.unknown()).then(() => void 0);
3234
3365
  }
3235
3366
  me() {
3236
3367
  return this.call("GET", "/me", MeResponseSchema);
@@ -3241,25 +3372,25 @@ var ServerClient = class {
3241
3372
  * credential. Null: each readable slug whatever `--org` says, which is how the caller's own slug is read.
3242
3373
  */
3243
3374
  listIntegrations(org) {
3244
- return this.call("GET", "/integrations", z13.array(IntegrationSchema), void 0, org);
3375
+ return this.call("GET", "/integrations", z14.array(IntegrationSchema), void 0, org);
3245
3376
  }
3246
3377
  /** What can be connected on this control plane, and by which kind of slug. */
3247
3378
  integrationCatalog() {
3248
- return this.call("GET", "/integrations/catalog", z13.array(IntegrationCatalogEntrySchema), void 0, null);
3379
+ return this.call("GET", "/integrations/catalog", z14.array(IntegrationCatalogEntrySchema), void 0, null);
3249
3380
  }
3250
3381
  // ---- API keys (`kvbox key …`, #189) ----
3251
3382
  listApiKeys() {
3252
- return this.call("GET", "/keys", z13.array(ApiKeySchema));
3383
+ return this.call("GET", "/keys", z14.array(ApiKeySchema));
3253
3384
  }
3254
3385
  createApiKey(req) {
3255
3386
  return this.call("POST", "/keys", CreatedApiKeySchema, req);
3256
3387
  }
3257
3388
  deleteApiKey(name) {
3258
- return this.call("DELETE", `/keys/${encodeURIComponent(name)}`, z13.unknown()).then(() => void 0);
3389
+ return this.call("DELETE", `/keys/${encodeURIComponent(name)}`, z14.unknown()).then(() => void 0);
3259
3390
  }
3260
3391
  // ---- orgs (`kvbox org …`) ----
3261
3392
  listOrgs() {
3262
- return this.call("GET", "/orgs", z13.array(OrgMembershipSchema));
3393
+ return this.call("GET", "/orgs", z14.array(OrgMembershipSchema));
3263
3394
  }
3264
3395
  createOrg(req) {
3265
3396
  return this.call("POST", "/orgs", CloudOrgSchema, req);
@@ -3268,16 +3399,16 @@ var ServerClient = class {
3268
3399
  return this.call("GET", `/orgs/${encodeURIComponent(slug)}`, OrgDetailSchema);
3269
3400
  }
3270
3401
  deleteOrg(slug) {
3271
- return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z13.undefined());
3402
+ return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z14.undefined());
3272
3403
  }
3273
3404
  addMember(slug, req) {
3274
- return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z13.undefined(), req);
3405
+ return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z14.undefined(), req);
3275
3406
  }
3276
3407
  setRole(slug, username, role) {
3277
- return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z13.unknown(), { role }).then(() => void 0);
3408
+ return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z14.unknown(), { role }).then(() => void 0);
3278
3409
  }
3279
3410
  removeMember(slug, username) {
3280
- return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z13.undefined());
3411
+ return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z14.undefined());
3281
3412
  }
3282
3413
  /** Sign this machine's key again (#51); the key must be one the user logged in with. */
3283
3414
  sshCert(req) {
@@ -3509,7 +3640,7 @@ async function select(message, choices, initial = 0) {
3509
3640
  ];
3510
3641
  out.write(`\r${ESC}[J${lines.join("\n")}
3511
3642
  `);
3512
- drawn = lines.reduce((n, l) => n + rows(l), 0);
3643
+ drawn = lines.reduce((n2, l) => n2 + rows(l), 0);
3513
3644
  };
3514
3645
  inp.setRawMode(true);
3515
3646
  inp.resume();
@@ -3705,7 +3836,7 @@ function parseDuration(text2) {
3705
3836
  const t = text2.trim().toLowerCase();
3706
3837
  if (!/^(\d+[mhd])+$/.test(t)) return void 0;
3707
3838
  let sec = 0;
3708
- for (const [, n, unit] of t.matchAll(/(\d+)([mhd])/g)) sec += Number(n) * UNIT_SEC[unit];
3839
+ for (const [, n2, unit] of t.matchAll(/(\d+)([mhd])/g)) sec += Number(n2) * UNIT_SEC[unit];
3709
3840
  return sec;
3710
3841
  }
3711
3842
 
@@ -3737,6 +3868,10 @@ async function noteNotConnected(client, box2, asked) {
3737
3868
  const row = rows2.find((r) => r.owner === slug && r.integration === id);
3738
3869
  if (row === void 0 || row.connected && row.status === "ok") continue;
3739
3870
  if (!row.connected && !connectable(catalog, id, slug === me(client))) {
3871
+ if (slug === me(client)) {
3872
+ info(color.dim(` ${id} is not set up on this control plane: it is on for this box, which gets nothing from it`));
3873
+ continue;
3874
+ }
3740
3875
  info(color.dim(` ${id} cannot be connected for an org yet: it is on for this box, which gets nothing from it until ${slug} can connect it`));
3741
3876
  continue;
3742
3877
  }
@@ -3746,7 +3881,7 @@ async function noteNotConnected(client, box2, asked) {
3746
3881
  }
3747
3882
 
3748
3883
  // src/commands/vm/new.ts
3749
- var newCommand = new Command("new").description("boot a new box from an image (the base one, or e.g. postgres) or a snapshot").argument("[name]", "box name (box1, box2, \u2026 when omitted)").addOption(new Option("-s, --size <size>", "box size (default: server config, s)").choices(SIZE_NAMES)).option("-b, --base <image>", "the image to boot: base (default) or one the host has, e.g. postgres").option("-e, --env <NAME=value>", "a variable of the box's own, over yours (repeatable; change later with kvbox env set --box)", collect, []).option("-f, --from <snapshot>", "start from a snapshot instead of an image").option("--from-backup <id>", "start on a backup's disk, a removed box's too (kvbox vm backup ls); image, variables and size come from it").option("--near <box>", "put it on the same host as this box, so the two can be linked (kvbox vm link)").option("--country <country>", "put it on a host in this country, a name or a code, e.g. romania or US").addOption(new Option("--host <name>", "put it on this host and no other (admins only)").hideHelp()).option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never; default: server config, off)").option("--integration <list>", "turn integrations on for the box, e.g. github,claude (connect the account in the web app; off: none)").option("--force", "skip the capacity guard").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
3884
+ var newCommand = new Command("new").description("boot a new box from an image (the base one, or e.g. postgres) or a snapshot").argument("[name]", "box name (box1, box2, \u2026 when omitted)").addOption(new Option("-s, --size <size>", "box size (default: server config, s)").choices(SIZE_NAMES)).option("-b, --base <image>", "the image to boot: base (default) or one the host has, e.g. postgres").option("-e, --env <NAME=value>", "a variable of the box's own, over yours (repeatable; change later with kvbox env set --box)", collect, []).option("-f, --from <snapshot>", "start from a snapshot instead of an image").option("--from-backup <id>", "start on a backup's disk, a removed box's too (kvbox vm backup ls); image, variables and size come from it").option("--near <box>", "put it on the same host as this box, so a link between the two stays on that host (kvbox vm link)").option("--country <country>", "put it on a host in this country, a name or a code, e.g. romania or US").addOption(new Option("--host <name>", "put it on this host and no other (admins only)").hideHelp()).option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never; default: server config, off)").option("--integration <list>", "turn integrations on for the box, e.g. github,claude (connect the account in the web app; off: none)").option("--force", "skip the capacity guard").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
3750
3885
  const autoHibernateSec = opts.autoHibernate === void 0 ? void 0 : parseIdleTimeout(opts.autoHibernate);
3751
3886
  const env = parseEnvFlags(opts.env);
3752
3887
  const integrations = opts.integration === void 0 ? void 0 : parseIntegrationList(opts.integration);
@@ -3830,7 +3965,7 @@ var newCommand = new Command("new").description("boot a new box from an image (t
3830
3965
  async function keptVars(client, box2, names2) {
3831
3966
  try {
3832
3967
  const have = new Set((await client.boxEnv(box2)).vars.map((v) => v.name));
3833
- return names2.every((n) => have.has(n)) ? true : "too old";
3968
+ return names2.every((n2) => have.has(n2)) ? true : "too old";
3834
3969
  } catch (err) {
3835
3970
  const message = err.message;
3836
3971
  return /no route:|too old/.test(message) ? "too old" : message;
@@ -3935,9 +4070,9 @@ function collect2(value, previous) {
3935
4070
  return [...previous ?? [], value];
3936
4071
  }
3937
4072
  function positiveSeconds(value) {
3938
- const n = Number(value);
3939
- if (!Number.isFinite(n) || n <= 0) throw new InvalidArgumentError("expected a number of seconds > 0");
3940
- return n;
4073
+ const n2 = Number(value);
4074
+ if (!Number.isFinite(n2) || n2 <= 0) throw new InvalidArgumentError("expected a number of seconds > 0");
4075
+ return n2;
3941
4076
  }
3942
4077
  async function runSsh(ssh, opts) {
3943
4078
  const child = spawn2("ssh", ssh, { stdio: ["inherit", opts.json ? "pipe" : "inherit", opts.json ? "pipe" : "inherit"] });
@@ -4170,9 +4305,9 @@ function reaches(row, short = false) {
4170
4305
  }
4171
4306
  function parsePorts(texts) {
4172
4307
  return texts.map((t) => {
4173
- const n = Number(t);
4174
- if (!/^\d+$/.test(t) || n < 1 || n > 65535) throw new KvboxError(`"${t}" is not a port (1-65535)`);
4175
- return n;
4308
+ const n2 = Number(t);
4309
+ if (!/^\d+$/.test(t) || n2 < 1 || n2 > 65535) throw new KvboxError(`"${t}" is not a port (1-65535)`);
4310
+ return n2;
4176
4311
  });
4177
4312
  }
4178
4313
  async function findBox(client, text2) {
@@ -4256,7 +4391,7 @@ function parseLinkPort(text2) {
4256
4391
  if (!Number.isInteger(port) || port < 1 || port > 65535) throw new KvboxError(`--port: expected a port from 1 to 65535, got "${text2}"`);
4257
4392
  return port;
4258
4393
  }
4259
- var linkCommand = new Command9("link").description("let one box reach a port of another (private, same host; never public)").argument("<from>", "the box that connects").argument("<box>", "the box it may reach").requiredOption("-p, --port <port>", "the port in <box>").option("--json", "print the link as JSON").action(async (from, name, opts, cmd) => {
4394
+ var linkCommand = new Command9("link").description("let one box reach a port of another (private; never public)").argument("<from>", "the box that connects").argument("<box>", "the box it may reach").requiredOption("-p, --port <port>", "the port in <box>").option("--json", "print the link as JSON").action(async (from, name, opts, cmd) => {
4260
4395
  const port = parseLinkPort(opts.port);
4261
4396
  const client = await clientFor(cmd.optsWithGlobals());
4262
4397
  try {
@@ -4670,7 +4805,7 @@ var hookCommand = new Command22("hook").description("URLs that wake a box when c
4670
4805
  for (const cmd of hookCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
4671
4806
 
4672
4807
  // src/commands/vm/backup/index.ts
4673
- import { Command as Command28 } from "commander";
4808
+ import { Command as Command30 } from "commander";
4674
4809
 
4675
4810
  // src/commands/vm/backup/create.ts
4676
4811
  import { Command as Command24 } from "commander";
@@ -4696,13 +4831,13 @@ var usageCommand = new Command23("usage").description("how long a box ran, slept
4696
4831
  await client.close();
4697
4832
  }
4698
4833
  });
4699
- var day = (iso) => iso.slice(0, 10);
4834
+ var day = (iso2) => iso2.slice(0, 10);
4700
4835
  var SYMBOLS = { EUR: "\u20AC", USD: "$", GBP: "\xA3" };
4701
4836
  function money(amount, currency) {
4702
4837
  const sign = amount < 0 ? "-" : "";
4703
- const n = Math.abs(amount).toFixed(2);
4838
+ const n2 = Math.abs(amount).toFixed(2);
4704
4839
  const sym = SYMBOLS[currency.toUpperCase()];
4705
- return sym === void 0 ? `${sign}${n} ${currency}` : `${sign}${sym}${n}`;
4840
+ return sym === void 0 ? `${sign}${n2} ${currency}` : `${sign}${sym}${n2}`;
4706
4841
  }
4707
4842
  function block(u) {
4708
4843
  const estimated = u.estimatedStops === 0 ? "" : color.dim(` (${u.estimatedStops} stop time${u.estimatedStops === 1 ? "" : "s"} estimated)`);
@@ -4835,7 +4970,7 @@ var lsCommand4 = new Command25("ls").alias("list").description("list backups: ev
4835
4970
  data: b.dataBytes === null ? "-" : gbShort(b.dataBytes),
4836
4971
  uploaded: b.uploadedBytes === null ? "-" : gbShort(b.uploadedBytes),
4837
4972
  disk: b.diskBytes === null ? "-" : gbShort(b.diskBytes),
4838
- by: b.createdBy ?? "-",
4973
+ by: b.scheduled ? color.dim("schedule") : b.createdBy ?? "-",
4839
4974
  taken: age(b.createdAt),
4840
4975
  ...anyError ? { error: b.error ?? "" } : {}
4841
4976
  }))
@@ -4903,13 +5038,79 @@ var rmCommand3 = new Command27("rm").alias("remove").description("remove a backu
4903
5038
  }
4904
5039
  });
4905
5040
 
5041
+ // src/commands/vm/backup/schedule.ts
5042
+ import { Command as Command29 } from "commander";
5043
+
5044
+ // src/commands/vm/backup/nightly.ts
5045
+ import "commander";
5046
+ var scheduleFlags = (cmd) => cmd.option("--at <hour>", "back it up daily at this hour, 0-23 UTC (turns it on)").option("--off", "stop backing it up on its own").option("--on", "back it up on its own, at the hour it has").option("--json", "print the schedule as JSON");
5047
+ function changeOf(flags) {
5048
+ if (flags.off && (flags.on || flags.at !== void 0)) throw new KvboxError("--off takes neither --on nor --at");
5049
+ const hour = flags.at === void 0 ? void 0 : parseHour(flags.at);
5050
+ return { ...flags.off ? { enabled: false } : flags.on ? { enabled: true } : {}, ...hour !== void 0 ? { hour } : {} };
5051
+ }
5052
+ function parseHour(text2) {
5053
+ const m = /^(\d{1,2})(?::00)?$/.exec(text2.trim());
5054
+ const hour = m ? Number(m[1]) : NaN;
5055
+ if (!Number.isInteger(hour) || hour < 0 || hour > 23) throw new KvboxError(`--at ${text2}: an hour of the day, 0-23 (UTC), like 3 or 03:00`);
5056
+ return hour;
5057
+ }
5058
+ function scheduleLine(command, s, now = Date.now()) {
5059
+ const at = `${String(s.hour).padStart(2, "0")}:00 UTC`;
5060
+ if (!s.enabled) return color.dim(`not on their own (${command} --on, at ${at})`);
5061
+ const nextMs = s.nextAt === null ? null : Date.parse(s.nextAt) - now;
5062
+ const next = s.nextAt === null || nextMs === null ? "" : nextMs > -6e4 ? `, next in ${inHours(nextMs)}` : `, ${color.yellow(`due since ${s.nextAt.slice(0, 16).replace("T", " ")} UTC, waiting for the backup job`)}`;
5063
+ const failed = s.lastError !== null ? color.yellow(` last one failed: ${s.lastError}`) : "";
5064
+ return `daily at ${at}${next}${failed}`;
5065
+ }
5066
+ function inHours(ms2) {
5067
+ const min = Math.max(0, Math.round(ms2 / 6e4));
5068
+ if (min < 60) return `${min}m`;
5069
+ const h = Math.floor(min / 60);
5070
+ return h < 24 ? `${h}h ${min % 60}m` : `${Math.floor(h / 24)}d ${h % 24}h`;
5071
+ }
5072
+ function withOrg(client, command) {
5073
+ const org = client.target.kind === "cloud" ? client.target.org : void 0;
5074
+ return org ? `${command} --org ${org}` : command;
5075
+ }
5076
+ function printSchedule(what, command, schedule, flags, changed) {
5077
+ if (flags.json) {
5078
+ json(schedule);
5079
+ return;
5080
+ }
5081
+ const at = `${String(schedule.hour).padStart(2, "0")}:00 UTC`;
5082
+ const said = schedule.enabled ? scheduleLine(command, schedule) : color.dim(`not backed up on its own (${command} --on, at ${at})`);
5083
+ info(`${changed ? `${color.green("\u2713")} ` : ""}${what}: ${said}`);
5084
+ if (schedule.lastAt !== null) {
5085
+ const last = schedule.lastError !== null ? color.red(`failed: ${schedule.lastError}`) : schedule.lastBackup !== null ? `backup ${schedule.lastBackup}` : "starting a backup";
5086
+ info(color.dim(` last turn ${schedule.lastAt.slice(0, 16).replace("T", " ")} UTC: `) + last);
5087
+ }
5088
+ }
5089
+
5090
+ // src/commands/vm/backup/schedule.ts
5091
+ 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(
5092
+ async (name, flags, cmd) => {
5093
+ const change = changeOf(flags);
5094
+ const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
5095
+ try {
5096
+ requireCloud3(client);
5097
+ const box2 = displayName(await findBox(client, name), me(client));
5098
+ const changed = Object.keys(change).length > 0;
5099
+ const schedule = changed ? await client.setBoxBackupSchedule(box2, change) : await client.boxBackupSchedule(box2);
5100
+ printSchedule(`box ${box2}`, `kvbox vm backup schedule ${box2}`, schedule, flags, changed);
5101
+ } finally {
5102
+ await client.close();
5103
+ }
5104
+ }
5105
+ );
5106
+
4906
5107
  // src/commands/vm/backup/index.ts
4907
- var backupCommand = new Command28("backup").description("back up a box's disk to the kvbox cloud, list backups, restore or remove one").addCommand(createCommand2).addCommand(lsCommand4).addCommand(restoreCommand).addCommand(rmCommand3);
5108
+ var backupCommand = new Command30("backup").description("back up a box's disk to the kvbox cloud, list backups, restore or remove one").addCommand(createCommand2).addCommand(lsCommand4).addCommand(restoreCommand).addCommand(rmCommand3).addCommand(scheduleCommand);
4908
5109
  for (const cmd of backupCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
4909
5110
 
4910
5111
  // src/commands/vm/rescale.ts
4911
- import { Command as Command29, Option as Option3 } from "commander";
4912
- var rescaleCommand = new Command29("rescale").description("change a box's vCPUs, memory or disk (e.g. --vcpu 4 --mem 16GB); a running box restarts").argument("<name>", "box name").addOption(new Option3("-s, --size <size>", "a preset to start from").choices(SIZE_NAMES)).option("--vcpu <n>", "number of vCPUs").option("--mem <size>", "memory, e.g. 16GB or 4096MB").option("--disk <size>", "disk size, e.g. 32GB (grow only)").option("--force", "skip the capacity guard when a running box grows").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
5112
+ import { Command as Command31, Option as Option3 } from "commander";
5113
+ var rescaleCommand = new Command31("rescale").description("change a box's vCPUs, memory or disk (e.g. --vcpu 4 --mem 16GB); a running box restarts").argument("<name>", "box name").addOption(new Option3("-s, --size <size>", "a preset to start from").choices(SIZE_NAMES)).option("--vcpu <n>", "number of vCPUs").option("--mem <size>", "memory, e.g. 16GB or 4096MB").option("--disk <size>", "disk size, e.g. 32GB (grow only)").option("--force", "skip the capacity guard when a running box grows").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
4913
5114
  const req = {
4914
5115
  ...opts.size !== void 0 ? { size: opts.size } : {},
4915
5116
  ...opts.vcpu !== void 0 ? { vcpu: parseCount(opts.vcpu) } : {},
@@ -4939,9 +5140,9 @@ var rescaleCommand = new Command29("rescale").description("change a box's vCPUs,
4939
5140
  }
4940
5141
  });
4941
5142
  function parseCount(text2) {
4942
- const n = Number(text2);
4943
- if (!Number.isInteger(n) || n < 1) throw new KvboxError(`--vcpu ${text2}: give a whole number of vCPUs`);
4944
- return n;
5143
+ const n2 = Number(text2);
5144
+ if (!Number.isInteger(n2) || n2 < 1) throw new KvboxError(`--vcpu ${text2}: give a whole number of vCPUs`);
5145
+ return n2;
4945
5146
  }
4946
5147
  function parseSize(flag, text2) {
4947
5148
  const mib = parseMib(text2);
@@ -4955,8 +5156,8 @@ function parseGib(flag, text2) {
4955
5156
  }
4956
5157
 
4957
5158
  // src/commands/vm/resume.ts
4958
- import { Command as Command30 } from "commander";
4959
- var resumeCommand = new Command30("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) => {
5159
+ 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) => {
4960
5161
  const client = await clientFor(cmd.optsWithGlobals());
4961
5162
  try {
4962
5163
  const box2 = await spin(`resuming ${name}\u2026`, client.resumeMachine(name));
@@ -4968,8 +5169,8 @@ var resumeCommand = new Command30("resume").description("continue a box that is
4968
5169
  });
4969
5170
 
4970
5171
  // src/commands/vm/rm.ts
4971
- import { Command as Command31 } from "commander";
4972
- var rmCommand4 = new Command31("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) => {
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) => {
4973
5174
  const client = await clientFor(cmd.optsWithGlobals());
4974
5175
  try {
4975
5176
  const box2 = pickRef(await boxesFor(client, name), name, me(client));
@@ -4989,7 +5190,7 @@ var rmCommand4 = new Command31("rm").description("destroy a box (its disk is del
4989
5190
  });
4990
5191
 
4991
5192
  // src/commands/vm/set.ts
4992
- import { Command as Command32 } from "commander";
5193
+ import { Command as Command34 } from "commander";
4993
5194
 
4994
5195
  // src/swap.ts
4995
5196
  import { spawn as spawn4 } from "child_process";
@@ -5065,7 +5266,7 @@ function runSwap(ep, mib) {
5065
5266
  }
5066
5267
 
5067
5268
  // src/commands/vm/set.ts
5068
- var setCommand = new Command32("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) => {
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) => {
5069
5270
  if (opts.autoHibernate === void 0 && opts.idleCheck === void 0 && opts.integration === void 0 && opts.swap === void 0) {
5070
5271
  throw new KvboxError("nothing to change: give --auto-hibernate, --idle-check, --integration or --swap");
5071
5272
  }
@@ -5143,8 +5344,8 @@ function parseIdleCheck(text2) {
5143
5344
  }
5144
5345
 
5145
5346
  // src/commands/vm/start.ts
5146
- import { Command as Command33 } from "commander";
5147
- var startCommand = new Command33("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) => {
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) => {
5148
5349
  const client = await clientFor(cmd.optsWithGlobals());
5149
5350
  try {
5150
5351
  const box2 = await spin(`booting ${name}\u2026`, client.startMachine(name, opts.force ?? false));
@@ -5156,8 +5357,8 @@ var startCommand = new Command33("start").description("boot a stopped box again
5156
5357
  });
5157
5358
 
5158
5359
  // src/commands/vm/stop.ts
5159
- import { Command as Command34 } from "commander";
5160
- var stopCommand = new Command34("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) => {
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) => {
5161
5362
  const client = await clientFor(cmd.optsWithGlobals());
5162
5363
  try {
5163
5364
  const box2 = await spin(`shutting ${name} down\u2026`, client.stopMachine(name));
@@ -5169,8 +5370,8 @@ var stopCommand = new Command34("stop").description("shut a box down (its disk i
5169
5370
  });
5170
5371
 
5171
5372
  // src/commands/vm/top.ts
5172
- import { Command as Command35 } from "commander";
5173
- var topCommand = new Command35("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) => {
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) => {
5174
5375
  const client = await clientFor(cmd.optsWithGlobals());
5175
5376
  try {
5176
5377
  const running = (await client.listMachines({ all: opts.all })).filter((b) => b.status === "running");
@@ -5229,9 +5430,72 @@ function topRows(entries, cloud) {
5229
5430
  });
5230
5431
  }
5231
5432
 
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
+
5232
5496
  // src/commands/vm/unlink.ts
5233
- import { Command as Command36 } from "commander";
5234
- var unlinkCommand = new Command36("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) => {
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) => {
5235
5499
  const port = parseLinkPort(opts.port);
5236
5500
  if (!await confirm(`Cut box ${from} off from box ${name} port ${port}? Its open connections close too.`, opts.yes ?? false)) {
5237
5501
  info("cancelled");
@@ -5252,8 +5516,8 @@ var unlinkCommand = new Command36("unlink").description("take a link away (kvbox
5252
5516
  });
5253
5517
 
5254
5518
  // src/commands/vm/update.ts
5255
- import { Command as Command37 } from "commander";
5256
- var updateCommand = new Command37("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) => {
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) => {
5257
5521
  const client = await clientFor(cmd.optsWithGlobals());
5258
5522
  try {
5259
5523
  const before = pickRef(await boxesFor(client, name), name, me(client));
@@ -5275,8 +5539,8 @@ var updateCommand = new Command37("update").description("move a box onto the cur
5275
5539
  });
5276
5540
 
5277
5541
  // src/commands/vm/wake.ts
5278
- import { Command as Command38 } from "commander";
5279
- var wakeCommand = new Command38("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) => {
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) => {
5280
5544
  const client = await clientFor(cmd.optsWithGlobals());
5281
5545
  try {
5282
5546
  const box2 = await spin(`waking ${name} (loading its memory from disk)\u2026`, client.wakeMachine(name, opts.force ?? false));
@@ -5288,7 +5552,7 @@ var wakeCommand = new Command38("wake").description("continue a hibernated box w
5288
5552
  });
5289
5553
 
5290
5554
  // src/commands/vm/index.ts
5291
- var vmCommand = new Command39("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(topCommand).addCommand(proxyCommand).addCommand(hookCommand).addCommand(backupCommand).addCommand(linkCommand).addCommand(unlinkCommand).addCommand(linksCommand).addCommand(rmCommand4);
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);
5292
5556
  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)");
5293
5557
  var vmAliases = [newCommand, lsCommand, getCommand, connectCommand, execCommand, cpCommand, stopCommand, startCommand, pauseCommand, resumeCommand, hibernateCommand, wakeCommand, rmCommand4, claimCommand];
5294
5558
 
@@ -5297,7 +5561,7 @@ import { hostname as osHostname2 } from "os";
5297
5561
  import { createInterface as createInterface2 } from "readline/promises";
5298
5562
  import { setTimeout as sleep4 } from "timers/promises";
5299
5563
  import { Writable } from "stream";
5300
- import { Command as Command40 } from "commander";
5564
+ import { Command as Command43 } from "commander";
5301
5565
 
5302
5566
  // src/browser.ts
5303
5567
  import { spawn as spawn5 } from "child_process";
@@ -5334,7 +5598,7 @@ function openBrowser(url) {
5334
5598
  }
5335
5599
 
5336
5600
  // src/commands/login.ts
5337
- var loginCommand = new Command40("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) => {
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) => {
5338
5602
  const url = normalizeUrl(urlArg ?? DEFAULT_CLOUD_URL);
5339
5603
  const byPassword = opts.password === true || opts.passwordStdin === true || opts.email !== void 0;
5340
5604
  const session = byPassword ? await runLogin(url, await readCredentials(opts), paths()) : await runDeviceLogin(url, paths());
@@ -5444,8 +5708,8 @@ async function firstLine(stream) {
5444
5708
  }
5445
5709
 
5446
5710
  // src/commands/logout.ts
5447
- import { Command as Command41 } from "commander";
5448
- var logoutCommand = new Command41("logout").description("log out of the control plane; commands target this machine's kvbox-server again").action(async () => {
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 () => {
5449
5713
  const p = paths();
5450
5714
  const session = await readSession(p).catch(() => null);
5451
5715
  switch (await runLogout(p)) {
@@ -5483,8 +5747,8 @@ async function runLogout(p = paths()) {
5483
5747
  }
5484
5748
 
5485
5749
  // src/commands/whoami.ts
5486
- import { Command as Command42 } from "commander";
5487
- var whoamiCommand = new Command42("whoami").description("show which account and control plane commands target (or local mode)").option("--json", "print as JSON").action(async (opts, cmd) => {
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) => {
5488
5752
  if (!cmd.optsWithGlobals().local && envLogin()) {
5489
5753
  const target = await resolveTarget({});
5490
5754
  if (target.kind !== "cloud") return;
@@ -5509,10 +5773,10 @@ function describeSession(session) {
5509
5773
  }
5510
5774
 
5511
5775
  // src/commands/key/index.ts
5512
- import { Command as Command46 } from "commander";
5776
+ import { Command as Command49 } from "commander";
5513
5777
 
5514
5778
  // src/commands/key/create.ts
5515
- import { Command as Command43 } from "commander";
5779
+ import { Command as Command46 } from "commander";
5516
5780
 
5517
5781
  // src/commands/key/shared.ts
5518
5782
  async function keyClient(cmd) {
@@ -5549,7 +5813,7 @@ function expiryText(expiresAt, now = Date.now()) {
5549
5813
  }
5550
5814
 
5551
5815
  // src/commands/key/create.ts
5552
- var createCommand3 = new Command43("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) => {
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) => {
5553
5817
  const expiresAt = opts.expires === void 0 ? void 0 : parseExpires(opts.expires);
5554
5818
  const client = await keyClient(cmd);
5555
5819
  try {
@@ -5567,8 +5831,8 @@ var createCommand3 = new Command43("create").description("make an API key for a
5567
5831
  });
5568
5832
 
5569
5833
  // src/commands/key/ls.ts
5570
- import { Command as Command44 } from "commander";
5571
- var lsCommand5 = new Command44("ls").alias("list").description("list your API keys (never the keys themselves)").option("--json", "print as JSON").action(async (opts, cmd) => {
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) => {
5572
5836
  const client = await keyClient(cmd);
5573
5837
  try {
5574
5838
  const keys = await client.listApiKeys();
@@ -5587,8 +5851,8 @@ var lsCommand5 = new Command44("ls").alias("list").description("list your API ke
5587
5851
  });
5588
5852
 
5589
5853
  // src/commands/key/rm.ts
5590
- import { Command as Command45 } from "commander";
5591
- var rmCommand5 = new Command45("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) => {
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) => {
5592
5856
  const client = await keyClient(cmd);
5593
5857
  try {
5594
5858
  if (!await confirm(`Remove API key ${name}? Whatever uses it stops working.`, opts.yes ?? false)) {
@@ -5604,14 +5868,14 @@ var rmCommand5 = new Command45("rm").alias("remove").description("remove an API
5604
5868
  });
5605
5869
 
5606
5870
  // src/commands/key/index.ts
5607
- var keyCommand = new Command46("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);
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);
5608
5872
 
5609
5873
  // src/commands/integration/index.ts
5610
- import { Command as Command48 } from "commander";
5874
+ import { Command as Command51 } from "commander";
5611
5875
 
5612
5876
  // src/commands/integration/ls.ts
5613
- import { Command as Command47 } from "commander";
5614
- var lsCommand6 = new Command47("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) => {
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) => {
5615
5879
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
5616
5880
  try {
5617
5881
  if (client.target.kind !== "cloud") throw new KvboxError("integrations belong to an account on the kvbox cloud: kvbox login first");
@@ -5626,7 +5890,7 @@ var lsCommand6 = new Command47("ls").alias("list").description("list the account
5626
5890
  rows2.map((r) => ({
5627
5891
  slug: r.owner,
5628
5892
  integration: r.integration,
5629
- state: !open(r) ? color.dim("not for orgs yet") : !r.connected ? color.dim("not connected") : r.status === "needs-reconnect" ? color.yellow("connect again") : color.green("connected"),
5893
+ state: !open(r) ? color.dim(r.owner === me(client) ? "not set up here" : "not for orgs yet") : !r.connected ? color.dim("not connected") : r.status === "needs-reconnect" ? color.yellow("connect again") : color.green("connected"),
5630
5894
  account: r.account ?? "-",
5631
5895
  connected: r.connectedAt === null ? "-" : age(r.connectedAt),
5632
5896
  "last used": r.connected ? r.lastUsedAt === null ? "never" : age(r.lastUsedAt) : "-"
@@ -5640,14 +5904,14 @@ var lsCommand6 = new Command47("ls").alias("list").description("list the account
5640
5904
  });
5641
5905
 
5642
5906
  // src/commands/integration/index.ts
5643
- var integrationCommand = new Command48("integration").aliases(["integrations"]).description("integrations: accounts (GitHub, Claude Code) connected once in the web app and turned on per box with --integration").addCommand(lsCommand6);
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);
5644
5908
 
5645
5909
  // src/commands/snapshots/index.ts
5646
- import { Command as Command52 } from "commander";
5910
+ import { Command as Command55 } from "commander";
5647
5911
 
5648
5912
  // src/commands/snapshots/ls.ts
5649
- import { Command as Command49 } from "commander";
5650
- var lsCommand7 = new Command49("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) => {
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) => {
5651
5915
  const client = await clientFor(cmd.optsWithGlobals());
5652
5916
  try {
5653
5917
  const cloud = client.target.kind === "cloud";
@@ -5678,8 +5942,8 @@ var lsCommand7 = new Command49("ls").description("list snapshots (yours and your
5678
5942
  });
5679
5943
 
5680
5944
  // src/commands/snapshots/new.ts
5681
- import { Command as Command50 } from "commander";
5682
- var newCommand2 = new Command50("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) => {
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) => {
5683
5947
  const client = await clientFor(cmd.optsWithGlobals());
5684
5948
  try {
5685
5949
  const req = { box: box2, name, ...opts.replace ? { replace: true } : {} };
@@ -5692,8 +5956,8 @@ var newCommand2 = new Command50("new").description("freeze a running box (memory
5692
5956
  });
5693
5957
 
5694
5958
  // src/commands/snapshots/rm.ts
5695
- import { Command as Command51 } from "commander";
5696
- var rmCommand6 = new Command51("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) => {
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) => {
5697
5961
  if (!await confirm(`Delete snapshot ${name}?`, opts.yes ?? false)) {
5698
5962
  info("cancelled");
5699
5963
  process.exitCode = 1;
@@ -5709,14 +5973,14 @@ var rmCommand6 = new Command51("rm").description("delete a snapshot (boxes made
5709
5973
  });
5710
5974
 
5711
5975
  // src/commands/snapshots/index.ts
5712
- var snapshotsCommand = new Command52("snapshots").aliases(["snapshot", "snap"]).description("freeze running boxes into snapshots and manage them").addCommand(newCommand2).addCommand(lsCommand7).addCommand(rmCommand6);
5976
+ var snapshotsCommand = new Command55("snapshots").aliases(["snapshot", "snap"]).description("freeze running boxes into snapshots and manage them").addCommand(newCommand2).addCommand(lsCommand7).addCommand(rmCommand6);
5713
5977
  for (const cmd of snapshotsCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
5714
5978
 
5715
5979
  // src/commands/org/index.ts
5716
- import { Command as Command58 } from "commander";
5980
+ import { Command as Command61 } from "commander";
5717
5981
 
5718
5982
  // src/commands/org/ls.ts
5719
- import { Command as Command53 } from "commander";
5983
+ import { Command as Command56 } from "commander";
5720
5984
 
5721
5985
  // src/commands/org/context.ts
5722
5986
  var NOT_LOGGED_IN2 = "orgs live on the control plane: kvbox login first";
@@ -5736,7 +6000,7 @@ function orgFor(opts, target) {
5736
6000
  }
5737
6001
 
5738
6002
  // src/commands/org/ls.ts
5739
- var lsCommand8 = new Command53("ls").description("list the orgs you belong to and your role in each").option("--json", "print as JSON").action(async (opts, cmd) => {
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) => {
5740
6004
  const client = await cloudClientFor(cmd.optsWithGlobals());
5741
6005
  try {
5742
6006
  const orgs = await client.listOrgs();
@@ -5758,8 +6022,8 @@ function orgRows(orgs) {
5758
6022
  }
5759
6023
 
5760
6024
  // src/commands/org/members.ts
5761
- import { Command as Command54, Option as Option4 } from "commander";
5762
- var lsCommand9 = new Command54("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) => {
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) => {
5763
6027
  const client = await cloudClientFor(cmd.optsWithGlobals());
5764
6028
  try {
5765
6029
  const org = await client.getOrg(orgFor(opts, client.target));
@@ -5773,7 +6037,7 @@ var lsCommand9 = new Command54("ls").description("list an org's members and thei
5773
6037
  await client.close();
5774
6038
  }
5775
6039
  });
5776
- var addCommand2 = new Command54("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) => {
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) => {
5777
6041
  const client = await cloudClientFor(cmd.optsWithGlobals());
5778
6042
  try {
5779
6043
  const slug = orgFor(opts, client.target);
@@ -5783,7 +6047,7 @@ var addCommand2 = new Command54("add").description("add a user to an org (admins
5783
6047
  await client.close();
5784
6048
  }
5785
6049
  });
5786
- var rmCommand7 = new Command54("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) => {
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) => {
5787
6051
  const client = await cloudClientFor(cmd.optsWithGlobals());
5788
6052
  try {
5789
6053
  const slug = orgFor(opts, client.target);
@@ -5799,11 +6063,11 @@ var rmCommand7 = new Command54("rm").description("remove a member (or leave: rem
5799
6063
  await client.close();
5800
6064
  }
5801
6065
  });
5802
- var membersCommand = new Command54("members").description("who is in an org and what they may do").addCommand(lsCommand9).addCommand(addCommand2).addCommand(rmCommand7);
6066
+ var membersCommand = new Command57("members").description("who is in an org and what they may do").addCommand(lsCommand9).addCommand(addCommand2).addCommand(rmCommand7);
5803
6067
 
5804
6068
  // src/commands/org/new.ts
5805
- import { Command as Command55 } from "commander";
5806
- var newCommand3 = new Command55("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) => {
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) => {
5807
6071
  const client = await cloudClientFor(cmd.optsWithGlobals());
5808
6072
  try {
5809
6073
  const org = await client.createOrg({ slug, name: opts.name ?? slug });
@@ -5819,8 +6083,8 @@ var newCommand3 = new Command55("new").description("create an org; you become it
5819
6083
  });
5820
6084
 
5821
6085
  // src/commands/org/rm.ts
5822
- import { Command as Command56 } from "commander";
5823
- var rmCommand8 = new Command56("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) => {
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) => {
5824
6088
  if (!await confirm(`Delete org ${slug}? Its members lose access; its slug stays taken.`, opts.yes ?? false)) {
5825
6089
  info("cancelled");
5826
6090
  process.exitCode = 1;
@@ -5836,8 +6100,8 @@ var rmCommand8 = new Command56("rm").description("delete an org (owners only; re
5836
6100
  });
5837
6101
 
5838
6102
  // src/commands/org/role.ts
5839
- import { Argument, Command as Command57 } from "commander";
5840
- var roleCommand = new Command57("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) => {
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) => {
5841
6105
  const client = await cloudClientFor(cmd.optsWithGlobals());
5842
6106
  try {
5843
6107
  const slug = orgFor(opts, client.target);
@@ -5849,11 +6113,11 @@ var roleCommand = new Command57("role").description("change a member's role (own
5849
6113
  });
5850
6114
 
5851
6115
  // src/commands/org/index.ts
5852
- var orgCommand = new Command58("org").description("orgs: shared slugs that own boxes, with owners, admins and members").addCommand(lsCommand8).addCommand(newCommand3).addCommand(membersCommand).addCommand(roleCommand).addCommand(rmCommand8);
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);
5853
6117
 
5854
6118
  // src/commands/usage.ts
5855
- import { Command as Command59 } from "commander";
5856
- var usageCommand2 = new Command59("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) => {
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) => {
5857
6121
  for (const [name, value] of [
5858
6122
  ["since", opts.since],
5859
6123
  ["until", opts.until]
@@ -5891,7 +6155,7 @@ var usageCommand2 = new Command59("usage").description("what your boxes and volu
5891
6155
  table(cronRows(report, cloud));
5892
6156
  }
5893
6157
  if (backups.length > 0) {
5894
- const taken = backups.reduce((n, b) => n + b.count, 0);
6158
+ const taken = backups.reduce((n2, b) => n2 + b.count, 0);
5895
6159
  info(taken === 1 ? "1 backup taken by hand" : `${taken} backups taken by hand`);
5896
6160
  table(backupRows(report, cloud));
5897
6161
  }
@@ -5907,7 +6171,7 @@ var usageCommand2 = new Command59("usage").description("what your boxes and volu
5907
6171
  await client.close();
5908
6172
  }
5909
6173
  });
5910
- var day2 = (iso) => iso.slice(0, 10);
6174
+ var day2 = (iso2) => iso2.slice(0, 10);
5911
6175
  async function creditLine(client, me2) {
5912
6176
  let b;
5913
6177
  try {
@@ -5952,7 +6216,7 @@ function usageRows(report, cloud) {
5952
6216
  });
5953
6217
  return rows2;
5954
6218
  }
5955
- var sumCost = (rows2) => round(rows2.reduce((n, r) => n + (r.cost?.amount ?? 0), 0), 4);
6219
+ var sumCost = (rows2) => round(rows2.reduce((n2, r) => n2 + (r.cost?.amount ?? 0), 0), 4);
5956
6220
  function volumeRows(report, cloud) {
5957
6221
  const priced = report.totals.cost !== void 0;
5958
6222
  const volumes = report.volumes ?? [];
@@ -6020,7 +6284,7 @@ function byUser(report) {
6020
6284
  const users = [...groups].map(([user, boxes]) => {
6021
6285
  const { cost: _none, ...sum } = sumUsage(boxes);
6022
6286
  const u = { user, boxes: boxes.length, ...sum };
6023
- if (currency !== void 0) u.cost = { amount: round(boxes.reduce((n, b) => n + (b.cost?.amount ?? 0), 0), 4), currency };
6287
+ if (currency !== void 0) u.cost = { amount: round(boxes.reduce((n2, b) => n2 + (b.cost?.amount ?? 0), 0), 4), currency };
6024
6288
  return u;
6025
6289
  });
6026
6290
  users.sort((a, b) => a.user === null ? 1 : b.user === null ? -1 : a.user.localeCompare(b.user));
@@ -6042,7 +6306,7 @@ function userRows(r) {
6042
6306
  }));
6043
6307
  rows2.push({
6044
6308
  user: color.bold("total"),
6045
- boxes: String(r.users.reduce((n, u) => n + u.boxes, 0)),
6309
+ boxes: String(r.users.reduce((n2, u) => n2 + u.boxes, 0)),
6046
6310
  ...cells(r.totals),
6047
6311
  ...priced ? { cost: `${money(sumCost(r.users), r.totals.cost.currency)} ${color.dim("(estimated)")}` } : {}
6048
6312
  });
@@ -6050,8 +6314,8 @@ function userRows(r) {
6050
6314
  }
6051
6315
 
6052
6316
  // src/commands/credit.ts
6053
- import { Command as Command60 } from "commander";
6054
- var creditCommand = new Command60("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) => {
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) => {
6055
6319
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
6056
6320
  try {
6057
6321
  if (client.target.kind === "local") throw new KvboxError("credit lives on the control plane: kvbox login first");
@@ -6080,8 +6344,8 @@ function creditRow(b, me2) {
6080
6344
  }
6081
6345
 
6082
6346
  // src/commands/redeem.ts
6083
- import { Command as Command61 } from "commander";
6084
- var redeemCommand = new Command61("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) => {
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) => {
6085
6349
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
6086
6350
  try {
6087
6351
  if (client.target.kind === "local") throw new KvboxError("codes are redeemed on the control plane: kvbox login first");
@@ -6101,12 +6365,12 @@ var redeemCommand = new Command61("redeem").description("redeem a promo code for
6101
6365
  // src/commands/deploy/index.ts
6102
6366
  import { access as access5, readFile as readFile7 } from "fs/promises";
6103
6367
  import { basename as basename2, resolve as resolve3 } from "path";
6104
- import { Command as Command62, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
6368
+ import { Command as Command65, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
6105
6369
 
6106
6370
  // src/commands/deploy/config.ts
6107
6371
  import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
6108
6372
  import { isAbsolute, join as join6, normalize, relative as relative2 } from "path";
6109
- import { z as z14 } from "zod";
6373
+ import { z as z15 } from "zod";
6110
6374
 
6111
6375
  // src/commands/deploy/templates/docker.ts
6112
6376
  import { readFile as readFile4 } from "fs/promises";
@@ -6530,21 +6794,21 @@ function detectTemplates(pkg, dir = NO_FACTS) {
6530
6794
  var DEPLOY_AUTO_HIBERNATE_SEC = 3600;
6531
6795
  var CONFIG_FILE = "kvbox.json";
6532
6796
  var BOX_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
6533
- var DeployConfigSchema = z14.object({
6534
- template: z14.enum(TEMPLATE_IDS),
6535
- name: z14.string().regex(BOX_NAME_RE, "1-12 chars, lowercase letters, digits and '-', starting with a letter or digit"),
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"),
6536
6800
  /** The org whose box it is; absent for the user's own. */
6537
- org: z14.string().regex(ORG_SLUG_RE, "not an org slug").optional(),
6801
+ org: z15.string().regex(ORG_SLUG_RE, "not an org slug").optional(),
6538
6802
  /** The HTTPS name (`<subdomain>.kvbox.app`); absent when deploying to this machine's own host. */
6539
- subdomain: z14.string().check((ctx) => {
6803
+ subdomain: z15.string().check((ctx) => {
6540
6804
  const problem = subdomainProblem(ctx.value);
6541
6805
  if (problem) ctx.issues.push({ code: "custom", message: problem, input: ctx.value });
6542
6806
  }).optional(),
6543
- size: z14.enum(SIZE_NAMES).optional(),
6807
+ size: z15.enum(SIZE_NAMES).optional(),
6544
6808
  /** The build output directory, relative to the app; the template's default when absent. */
6545
- dist: z14.string().optional(),
6809
+ dist: z15.string().optional(),
6546
6810
  /** The port a Next.js app or Node server serves; the template's (3000) when absent. */
6547
- port: z14.number().int().min(1).max(65535).optional()
6811
+ port: z15.number().int().min(1).max(65535).optional()
6548
6812
  });
6549
6813
  var SERVICE_KEY_RE = /^[a-z][a-z0-9-]{0,19}$/;
6550
6814
  var RESERVED_SERVICE_KEYS = ["app", "agent", "init", "volumes"];
@@ -6556,38 +6820,38 @@ var POSTGRES_PORT = 5432;
6556
6820
  var POSTGRES_IMAGE = "postgres:17";
6557
6821
  var POSTGRES_ENV = "DATABASE_URL";
6558
6822
  var IMAGE_RE = /^[a-z0-9][a-z0-9._/:@-]*$/;
6559
- var ServiceSchema = z14.strictObject({
6560
- template: z14.enum([...TEMPLATE_IDS, POSTGRES]),
6823
+ var ServiceSchema = z15.strictObject({
6824
+ template: z15.enum([...TEMPLATE_IDS, POSTGRES]),
6561
6825
  /** The service's directory, relative to the one holding kvbox.json; every template but postgres has one. */
6562
- dir: z14.string().min(1).optional(),
6826
+ dir: z15.string().min(1).optional(),
6563
6827
  /** A postgres service's image, `postgres:17` when absent (`pgvector/pgvector:pg17` for vectors). */
6564
- image: z14.string().regex(IMAGE_RE, "an image name like postgres:17").optional(),
6828
+ image: z15.string().regex(IMAGE_RE, "an image name like postgres:17").optional(),
6565
6829
  /** The volume (a key of `volumes`) a postgres service keeps its data on. */
6566
- volume: z14.string().optional(),
6830
+ volume: z15.string().optional(),
6567
6831
  /** The box variable a postgres service's URL is written to, `DATABASE_URL` when absent. */
6568
- env: z14.string().optional(),
6832
+ env: z15.string().optional(),
6569
6833
  /** 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`. */
6570
- context: z14.string().min(1).optional(),
6571
- dist: z14.string().optional(),
6834
+ context: z15.string().min(1).optional(),
6835
+ dist: z15.string().optional(),
6572
6836
  /**
6573
6837
  * A command run once per deploy in the service's new version (a docker service: in a container of
6574
6838
  * the new image; node, nextjs: in the new source, installed and built), with the box's variables,
6575
6839
  * before it replaces the running one. Migrations, mostly. A failing one stops that service's deploy.
6576
6840
  */
6577
- release: z14.string().optional(),
6841
+ release: z15.string().optional(),
6578
6842
  /** The box port of a service with its own server; the template's (3000) when absent. */
6579
- port: z14.number().int().min(1).max(65535).optional(),
6843
+ port: z15.number().int().min(1).max(65535).optional(),
6580
6844
  /** The URL paths that go to this service, each with everything under it; the prefix is kept. */
6581
- paths: z14.array(z14.string().regex(ROUTE_RE, "a path like / or /api, no trailing slash")).min(1).optional()
6845
+ paths: z15.array(z15.string().regex(ROUTE_RE, "a path like / or /api, no trailing slash")).min(1).optional()
6582
6846
  });
6583
- var StackConfigSchema = z14.strictObject({
6847
+ var StackConfigSchema = z15.strictObject({
6584
6848
  name: DeployConfigSchema.shape.name.optional(),
6585
6849
  org: DeployConfigSchema.shape.org,
6586
6850
  subdomain: DeployConfigSchema.shape.subdomain,
6587
6851
  size: DeployConfigSchema.shape.size,
6588
6852
  /** The stack's volumes, name to size ("10GB"): made for its box and attached to it on the first deploy that needs one. */
6589
- volumes: z14.record(z14.string(), z14.string()).optional(),
6590
- services: z14.record(z14.string(), ServiceSchema)
6853
+ volumes: z15.record(z15.string(), z15.string()).optional(),
6854
+ services: z15.record(z15.string(), ServiceSchema)
6591
6855
  });
6592
6856
  function volumeGib(text2) {
6593
6857
  const mib = parseMib(text2);
@@ -6965,16 +7229,16 @@ var PROXY = (port) => [
6965
7229
  "proxy_buffering off;",
6966
7230
  "proxy_read_timeout 3600s;"
6967
7231
  ];
6968
- var block2 = (head, body) => [` ${head} {`, ...body.map((l) => ` ${l}`), " }", ""];
7232
+ var block3 = (head, body) => [` ${head} {`, ...body.map((l) => ` ${l}`), " }", ""];
6969
7233
  function locations(service, path) {
6970
7234
  const dist = `/srv/app/${service.key}/dist`;
6971
7235
  if (service.static) {
6972
- if (path === "/") return block2("location /", [`root ${dist};`, "try_files $uri $uri/ /index.html;"]);
6973
- return [...block2(`location = ${path}`, [`return 301 ${path}/;`]), ...block2(`location ${path}/`, [`alias ${dist}/;`, `try_files $uri $uri/ ${path}/index.html;`])];
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;`])];
6974
7238
  }
6975
7239
  const proxy = PROXY(service.port);
6976
- if (path === "/") return block2("location /", proxy);
6977
- return [...block2(`location = ${path}`, proxy), ...block2(`location ${path}/`, proxy)];
7240
+ if (path === "/") return block3("location /", proxy);
7241
+ return [...block3(`location = ${path}`, proxy), ...block3(`location ${path}/`, proxy)];
6978
7242
  }
6979
7243
  function stackSite(services) {
6980
7244
  const routed = services.flatMap((s) => s.paths.map((path) => ({ service: s, path })));
@@ -7002,7 +7266,7 @@ function stackSite(services) {
7002
7266
  "",
7003
7267
  ...routed.flatMap((r) => locations(r.service, r.path)),
7004
7268
  // No service at the top: say so instead of nginx's own welcome page.
7005
- ...root ? [] : block2("location /", ["return 404;"]),
7269
+ ...root ? [] : block3("location /", ["return 404;"]),
7006
7270
  "}",
7007
7271
  ""
7008
7272
  ].join("\n");
@@ -7348,12 +7612,12 @@ function defaultVolumes(box2, stackVolumes, account, keys) {
7348
7612
  });
7349
7613
  }
7350
7614
  function volumeNameFor(box2, taken, account = /* @__PURE__ */ new Set()) {
7351
- const free = (n) => taken[n] === void 0 && !account.has(n);
7615
+ const free = (n2) => taken[n2] === void 0 && !account.has(n2);
7352
7616
  const base = `${box2.slice(0, 9).replace(/-+$/, "")}-db`;
7353
7617
  if (free(base)) return base;
7354
7618
  for (let i = 2; ; i++) {
7355
- const n = `${box2.slice(0, 8).replace(/-+$/, "")}-db${i}`;
7356
- if (free(n)) return n;
7619
+ const n2 = `${box2.slice(0, 8).replace(/-+$/, "")}-db${i}`;
7620
+ if (free(n2)) return n2;
7357
7621
  }
7358
7622
  }
7359
7623
  async function readPackageJson(dir) {
@@ -7366,7 +7630,7 @@ async function readPackageJson(dir) {
7366
7630
  }
7367
7631
 
7368
7632
  // src/commands/deploy/index.ts
7369
- var deployCommand = new Command62("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) => {
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) => {
7370
7634
  const dir = resolve3(dirArg ?? ".");
7371
7635
  const pkg = await readPackageJson2(dir);
7372
7636
  const facts = { indexHtml: await exists2(resolve3(dir, "index.html")), dockerfile: await exists2(resolve3(dir, "Dockerfile")) };
@@ -7430,8 +7694,8 @@ var deployCommand = new Command62("deploy").description("put the app in this dir
7430
7694
  }
7431
7695
  });
7432
7696
  function portProblem(v) {
7433
- const n = Number(v);
7434
- return !/^\d+$/.test(v) || n < 1 || n > 65535;
7697
+ const n2 = Number(v);
7698
+ return !/^\d+$/.test(v) || n2 < 1 || n2 > 65535;
7435
7699
  }
7436
7700
  function parsePort(v) {
7437
7701
  if (portProblem(v)) throw new InvalidArgumentError2("expected a port, 1-65535");
@@ -7523,15 +7787,15 @@ async function settle2(dir, pkg, facts, saved, opts, orgFlag, cloud) {
7523
7787
  }
7524
7788
 
7525
7789
  // src/commands/volume/index.ts
7526
- import { Command as Command74 } from "commander";
7790
+ import { Command as Command78 } from "commander";
7527
7791
 
7528
7792
  // src/commands/volume/attach.ts
7529
- import { Command as Command63 } from "commander";
7793
+ import { Command as Command66 } from "commander";
7530
7794
  function describeMount(machine, volume2, box2) {
7531
7795
  const path = machine.volumes?.find((v) => volume2 === v.name || volume2.endsWith(`/${v.name}`))?.mountPath ?? volumeMountPath(volume2.slice(volume2.lastIndexOf("/") + 1));
7532
7796
  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`;
7533
7797
  }
7534
- var attachCommand = new Command63("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) => {
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) => {
7535
7799
  if (volumeArg === void 0 || boxArg === void 0) askOrUsage("give the volume and the box: kvbox volume attach <volume> <box>");
7536
7800
  const client = await clientFor(cmd.optsWithGlobals());
7537
7801
  try {
@@ -7550,11 +7814,11 @@ var attachCommand = new Command63("attach").description("attach a volume to a bo
7550
7814
  });
7551
7815
 
7552
7816
  // src/commands/volume/backup/index.ts
7553
- import { Command as Command68 } from "commander";
7817
+ import { Command as Command72 } from "commander";
7554
7818
 
7555
7819
  // src/commands/volume/backup/create.ts
7556
- import { Command as Command64 } from "commander";
7557
- var createCommand4 = new Command64("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) => {
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) => {
7558
7822
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7559
7823
  try {
7560
7824
  requireCloud3(client);
@@ -7581,8 +7845,8 @@ var createCommand4 = new Command64("create").description("back up a volume's dis
7581
7845
  });
7582
7846
 
7583
7847
  // src/commands/volume/backup/ls.ts
7584
- import { Command as Command65 } from "commander";
7585
- var lsCommand10 = new Command65("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) => {
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) => {
7586
7850
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7587
7851
  try {
7588
7852
  requireCloud3(client);
@@ -7604,7 +7868,7 @@ var lsCommand10 = new Command65("ls").alias("list").description("list volume bac
7604
7868
  data: b.dataBytes === null ? "-" : gbShort(b.dataBytes),
7605
7869
  uploaded: b.uploadedBytes === null ? "-" : gbShort(b.uploadedBytes),
7606
7870
  size: b.diskBytes === null ? "-" : gbShort(b.diskBytes),
7607
- by: b.createdBy ?? "-",
7871
+ by: b.scheduled ? color.dim("schedule") : b.createdBy ?? "-",
7608
7872
  taken: age(b.createdAt),
7609
7873
  ...anyError ? { error: b.error ?? "" } : {}
7610
7874
  }))
@@ -7615,8 +7879,8 @@ var lsCommand10 = new Command65("ls").alias("list").description("list volume bac
7615
7879
  });
7616
7880
 
7617
7881
  // src/commands/volume/backup/restore.ts
7618
- import { Command as Command66 } from "commander";
7619
- var restoreCommand2 = new Command66("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) => {
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) => {
7620
7884
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7621
7885
  try {
7622
7886
  requireCloud3(client);
@@ -7639,8 +7903,8 @@ var restoreCommand2 = new Command66("restore").description("put a backup back: t
7639
7903
  });
7640
7904
 
7641
7905
  // src/commands/volume/backup/rm.ts
7642
- import { Command as Command67 } from "commander";
7643
- var rmCommand9 = new Command67("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) => {
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) => {
7644
7908
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7645
7909
  try {
7646
7910
  requireCloud3(client);
@@ -7650,12 +7914,29 @@ var rmCommand9 = new Command67("rm").alias("remove").description("remove a backu
7650
7914
  }
7651
7915
  });
7652
7916
 
7917
+ // src/commands/volume/backup/schedule.ts
7918
+ import { Command as Command71 } from "commander";
7919
+ 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")
7921
+ ).action(async (volume2, flags, cmd) => {
7922
+ const change = changeOf(flags);
7923
+ const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7924
+ try {
7925
+ requireCloud3(client);
7926
+ const changed = Object.keys(change).length > 0;
7927
+ const schedule = changed ? await client.setVolumeBackupSchedule(volume2, change) : await client.volumeBackupSchedule(volume2);
7928
+ printSchedule(`volume ${volume2}`, withOrg(client, `kvbox volume backup schedule ${volume2}`), schedule, flags, changed);
7929
+ } finally {
7930
+ await client.close();
7931
+ }
7932
+ });
7933
+
7653
7934
  // src/commands/volume/backup/index.ts
7654
- var backupCommand2 = new Command68("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);
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);
7655
7936
  for (const cmd of backupCommand2.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
7656
7937
 
7657
7938
  // src/commands/volume/create.ts
7658
- import { Command as Command69 } from "commander";
7939
+ import { Command as Command73 } from "commander";
7659
7940
  function parseGib2(text2, label = "--size") {
7660
7941
  const mib = parseMib(text2);
7661
7942
  if (mib === void 0 || mib % 1024 !== 0) throw new KvboxError(`${label} ${text2}: write whole GB, like 50 or 50GB`);
@@ -7671,7 +7952,7 @@ function sizeProblem(answer) {
7671
7952
  return err instanceof KvboxError ? err.message.replace(/^--size \S+: /, "") : String(err);
7672
7953
  }
7673
7954
  }
7674
- var createCommand5 = new Command69("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) => {
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) => {
7675
7956
  const ask = interactive();
7676
7957
  if (nameArg === void 0 || opts.size === void 0) askOrUsage("give the name and the size: kvbox volume create <name> --size <gb> --box <box>");
7677
7958
  const name = nameArg ?? await text("Volume name", { validate: (a) => VOLUME_NAME_RE.test(a) ? void 0 : VOLUME_NAME_RULE });
@@ -7704,8 +7985,8 @@ var createCommand5 = new Command69("create").alias("new").description("create a
7704
7985
  });
7705
7986
 
7706
7987
  // src/commands/volume/detach.ts
7707
- import { Command as Command70 } from "commander";
7708
- var detachCommand = new Command70("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) => {
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) => {
7709
7990
  if (volumeArg === void 0) askOrUsage("give the volume: kvbox volume detach <volume> [box]");
7710
7991
  const client = await clientFor(cmd.optsWithGlobals());
7711
7992
  try {
@@ -7730,8 +8011,8 @@ var detachCommand = new Command70("detach").description("detach a volume from a
7730
8011
  });
7731
8012
 
7732
8013
  // src/commands/volume/grow.ts
7733
- import { Command as Command71 } from "commander";
7734
- var growCommand = new Command71("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) => {
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) => {
7735
8016
  const sizeGib = parseGib2(size, "size");
7736
8017
  const client = await clientFor(cmd.optsWithGlobals());
7737
8018
  try {
@@ -7744,8 +8025,8 @@ var growCommand = new Command71("grow").alias("resize").description("make a volu
7744
8025
  });
7745
8026
 
7746
8027
  // src/commands/volume/ls.ts
7747
- import { Command as Command72 } from "commander";
7748
- var lsCommand11 = new Command72("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) => {
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) => {
7749
8030
  const client = await clientFor(cmd.optsWithGlobals());
7750
8031
  try {
7751
8032
  const cloud = client.target.kind === "cloud";
@@ -7776,8 +8057,8 @@ var lsCommand11 = new Command72("ls").alias("list").description("list volumes: s
7776
8057
  });
7777
8058
 
7778
8059
  // src/commands/volume/rm.ts
7779
- import { Command as Command73 } from "commander";
7780
- var rmCommand10 = new Command73("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) => {
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) => {
7781
8062
  if (!await confirm(`Delete volume ${name} and everything on it?`, opts.yes ?? false)) {
7782
8063
  info("cancelled");
7783
8064
  process.exitCode = 1;
@@ -7793,18 +8074,18 @@ var rmCommand10 = new Command73("rm").alias("remove").description("delete a volu
7793
8074
  });
7794
8075
 
7795
8076
  // src/commands/volume/index.ts
7796
- var volumeCommand = new Command74("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);
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);
7797
8078
  for (const cmd of volumeCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
7798
8079
  volumeCommand.addCommand(backupCommand2);
7799
8080
 
7800
8081
  // src/commands/bucket/index.ts
7801
- import { Command as Command90 } from "commander";
8082
+ import { Command as Command95 } from "commander";
7802
8083
 
7803
8084
  // src/commands/bucket/backup/index.ts
7804
- import { Command as Command79 } from "commander";
8085
+ import { Command as Command84 } from "commander";
7805
8086
 
7806
8087
  // src/commands/bucket/backup/create.ts
7807
- import { Command as Command75 } from "commander";
8088
+ import { Command as Command79 } from "commander";
7808
8089
 
7809
8090
  // src/commands/bucket/shared.ts
7810
8091
  async function bucketClient(cmd) {
@@ -7830,7 +8111,7 @@ function printRows(rows2) {
7830
8111
  }
7831
8112
 
7832
8113
  // src/commands/bucket/backup/create.ts
7833
- var createCommand6 = new Command75("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) => {
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) => {
7834
8115
  const client = await bucketClient(cmd);
7835
8116
  const ls = "kvbox bucket backup ls";
7836
8117
  try {
@@ -7858,8 +8139,8 @@ var createCommand6 = new Command75("create").description("back up your object st
7858
8139
  });
7859
8140
 
7860
8141
  // src/commands/bucket/backup/ls.ts
7861
- import { Command as Command76 } from "commander";
7862
- var lsCommand12 = new Command76("ls").alias("list").description("list the backups of your object storage").option("--json", "print as JSON").action(async (opts, cmd) => {
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) => {
7863
8144
  const client = await bucketClient(cmd);
7864
8145
  try {
7865
8146
  const list = await client.storageBackups();
@@ -7880,7 +8161,7 @@ var lsCommand12 = new Command76("ls").alias("list").description("list the backup
7880
8161
  keys: b.keys,
7881
8162
  data: b.dataBytes === null ? "-" : gbShort(b.dataBytes),
7882
8163
  uploaded: b.uploadedBytes === null ? "-" : gbShort(b.uploadedBytes),
7883
- by: b.createdBy ?? "-",
8164
+ by: b.scheduled ? color.dim("schedule") : b.createdBy ?? "-",
7884
8165
  taken: age(b.createdAt),
7885
8166
  ...anyError ? { error: b.error ?? "" } : {}
7886
8167
  }))
@@ -7891,8 +8172,8 @@ var lsCommand12 = new Command76("ls").alias("list").description("list the backup
7891
8172
  });
7892
8173
 
7893
8174
  // src/commands/bucket/backup/restore.ts
7894
- import { Command as Command77 } from "commander";
7895
- var restoreCommand3 = new Command77("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) => {
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) => {
7896
8177
  const client = await bucketClient(cmd);
7897
8178
  try {
7898
8179
  const backup = await client.storageBackup(id);
@@ -7922,8 +8203,8 @@ var restoreCommand3 = new Command77("restore").description("put a backup back: e
7922
8203
  });
7923
8204
 
7924
8205
  // src/commands/bucket/backup/rm.ts
7925
- import { Command as Command78 } from "commander";
7926
- var rmCommand11 = new Command78("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) => {
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) => {
7927
8208
  const client = await bucketClient(cmd);
7928
8209
  try {
7929
8210
  const backup = (await client.storageBackups()).find((b) => b.id === id);
@@ -7941,12 +8222,28 @@ var rmCommand11 = new Command78("rm").alias("remove").description("remove a back
7941
8222
  }
7942
8223
  });
7943
8224
 
8225
+ // 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(
8228
+ async (flags, cmd) => {
8229
+ const change = changeOf(flags);
8230
+ const client = await bucketClient(cmd);
8231
+ try {
8232
+ const changed = Object.keys(change).length > 0;
8233
+ const schedule = changed ? await client.setStorageBackupSchedule(change) : await client.storageBackupSchedule();
8234
+ printSchedule("object storage", withOrg(client, "kvbox bucket backup schedule"), schedule, flags, changed);
8235
+ } finally {
8236
+ await client.close();
8237
+ }
8238
+ }
8239
+ );
8240
+
7944
8241
  // src/commands/bucket/backup/index.ts
7945
- var backupCommand3 = new Command79("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);
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);
7946
8243
 
7947
8244
  // src/commands/bucket/create.ts
7948
- import { Command as Command80 } from "commander";
7949
- var createCommand7 = new Command80("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) => {
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) => {
7950
8247
  const sizeGib = opts.size === void 0 ? void 0 : parseGib2(opts.size);
7951
8248
  const client = await bucketClient(cmd);
7952
8249
  try {
@@ -7966,8 +8263,8 @@ var createCommand7 = new Command80("create").description("make a bucket (the fir
7966
8263
  });
7967
8264
 
7968
8265
  // src/commands/bucket/grow.ts
7969
- import { Command as Command81 } from "commander";
7970
- var growCommand2 = new Command81("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) => {
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) => {
7971
8268
  const sizeGib = parseGib2(size, "size");
7972
8269
  const client = await bucketClient(cmd);
7973
8270
  try {
@@ -7980,8 +8277,8 @@ var growCommand2 = new Command81("grow").description("make your object storage l
7980
8277
  });
7981
8278
 
7982
8279
  // src/commands/bucket/info.ts
7983
- import { Command as Command82 } from "commander";
7984
- var infoCommand = new Command82("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) => {
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) => {
7985
8282
  const client = await bucketClient(cmd);
7986
8283
  try {
7987
8284
  const b = await client.getBucket(name);
@@ -8011,11 +8308,11 @@ with the AWS CLI: aws s3 ls s3://${b.name} --endpoint-url ${b.endpoint}`));
8011
8308
  });
8012
8309
 
8013
8310
  // src/commands/bucket/key/index.ts
8014
- import { Command as Command86 } from "commander";
8311
+ import { Command as Command91 } from "commander";
8015
8312
 
8016
8313
  // src/commands/bucket/key/create.ts
8017
- import { Command as Command83 } from "commander";
8018
- var createCommand8 = new Command83("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) => {
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) => {
8019
8316
  const client = await bucketClient(cmd);
8020
8317
  try {
8021
8318
  const key = await client.createBucketKey(bucket, { ...opts.name !== void 0 ? { name: opts.name } : {}, ...opts.readOnly ? { readOnly: true } : {} });
@@ -8038,8 +8335,8 @@ var createCommand8 = new Command83("create").description("make an access key for
8038
8335
  });
8039
8336
 
8040
8337
  // src/commands/bucket/key/ls.ts
8041
- import { Command as Command84 } from "commander";
8042
- var lsCommand13 = new Command84("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) => {
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) => {
8043
8340
  const client = await bucketClient(cmd);
8044
8341
  try {
8045
8342
  const keys = await client.listBucketKeys(bucket);
@@ -8058,8 +8355,8 @@ var lsCommand13 = new Command84("ls").alias("list").description("list a bucket's
8058
8355
  });
8059
8356
 
8060
8357
  // src/commands/bucket/key/rm.ts
8061
- import { Command as Command85 } from "commander";
8062
- var rmCommand12 = new Command85("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) => {
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) => {
8063
8360
  const client = await bucketClient(cmd);
8064
8361
  try {
8065
8362
  if (!await confirm(`Delete key ${id} of bucket ${bucket}? Whatever uses it stops working.`, opts.yes ?? false)) {
@@ -8075,11 +8372,11 @@ var rmCommand12 = new Command85("rm").alias("remove").description("delete an acc
8075
8372
  });
8076
8373
 
8077
8374
  // src/commands/bucket/key/index.ts
8078
- var keyCommand2 = new Command86("key").aliases(["keys"]).description("access keys of a bucket: what your app signs in with").addCommand(createCommand8).addCommand(lsCommand13).addCommand(rmCommand12);
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);
8079
8376
 
8080
8377
  // src/commands/bucket/ls.ts
8081
- import { Command as Command87 } from "commander";
8082
- var lsCommand14 = new Command87("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) => {
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) => {
8083
8380
  const client = await bucketClient(cmd);
8084
8381
  try {
8085
8382
  const buckets = await client.listBuckets({ all: opts.all });
@@ -8110,8 +8407,8 @@ var lsCommand14 = new Command87("ls").alias("list").description("list buckets, a
8110
8407
  });
8111
8408
 
8112
8409
  // src/commands/bucket/public.ts
8113
- import { Command as Command88 } from "commander";
8114
- var publicCommand = new Command88("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) => {
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) => {
8115
8412
  if (state !== "on" && state !== "off") throw new KvboxError(`"${state}": say on or off`);
8116
8413
  const on = state === "on";
8117
8414
  if (!on && opts.sub !== void 0) throw new KvboxError("--sub goes with on");
@@ -8139,8 +8436,8 @@ var publicCommand = new Command88("public").description("let anyone read a bucke
8139
8436
  });
8140
8437
 
8141
8438
  // src/commands/bucket/rm.ts
8142
- import { Command as Command89 } from "commander";
8143
- var rmCommand13 = new Command89("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) => {
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) => {
8144
8441
  const client = await bucketClient(cmd);
8145
8442
  try {
8146
8443
  const question = opts.force ? `Delete bucket ${name} with everything in it, and the object storage it is in?` : `Delete bucket ${name} and its keys?`;
@@ -8159,18 +8456,18 @@ var rmCommand13 = new Command89("rm").alias("remove").description("delete an emp
8159
8456
  });
8160
8457
 
8161
8458
  // src/commands/bucket/index.ts
8162
- var bucketCommand = new Command90("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);
8163
- var withOrg = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal buckets)");
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);
8460
+ var withOrg2 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal buckets)");
8164
8461
  for (const cmd of bucketCommand.commands) {
8165
- if (cmd === keyCommand2 || cmd === backupCommand3) cmd.commands.forEach(withOrg);
8166
- else withOrg(cmd);
8462
+ if (cmd === keyCommand2 || cmd === backupCommand3) cmd.commands.forEach(withOrg2);
8463
+ else withOrg2(cmd);
8167
8464
  }
8168
8465
 
8169
8466
  // src/commands/cron/index.ts
8170
- import { Command as Command103 } from "commander";
8467
+ import { Command as Command108 } from "commander";
8171
8468
 
8172
8469
  // src/commands/cron/create.ts
8173
- import { Command as Command91 } from "commander";
8470
+ import { Command as Command96 } from "commander";
8174
8471
 
8175
8472
  // src/commands/cron/shared.ts
8176
8473
  async function cronClient(cmd) {
@@ -8191,8 +8488,8 @@ function refFor(name, client) {
8191
8488
  return org && org !== user ? `${org}/${name}` : name;
8192
8489
  }
8193
8490
  var scheduleText = (t) => t.timezone === "UTC" ? t.expr : `${t.expr} (${t.timezone})`;
8194
- function until(iso, now = Date.now()) {
8195
- const sec = Math.round((Date.parse(iso) - now) / 1e3);
8491
+ function until(iso2, now = Date.now()) {
8492
+ const sec = Math.round((Date.parse(iso2) - now) / 1e3);
8196
8493
  return sec <= 0 ? "now" : `in ${duration(sec)}`;
8197
8494
  }
8198
8495
  function outcomeText(outcome) {
@@ -8231,7 +8528,7 @@ function printRows2(rows2) {
8231
8528
  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>")`);
8232
8529
 
8233
8530
  // src/commands/cron/create.ts
8234
- var createCommand9 = new Command91("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) => {
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) => {
8235
8532
  const client = await cronClient(cmd);
8236
8533
  try {
8237
8534
  const service = await client.createCronService(name);
@@ -8248,8 +8545,8 @@ var createCommand9 = new Command91("create").description("make a cron service: a
8248
8545
  });
8249
8546
 
8250
8547
  // src/commands/cron/info.ts
8251
- import { Command as Command92 } from "commander";
8252
- var infoCommand2 = new Command92("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) => {
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) => {
8253
8550
  const client = await cronClient(cmd);
8254
8551
  try {
8255
8552
  const service = await client.getCronService(name);
@@ -8273,8 +8570,8 @@ var infoCommand2 = new Command92("info").alias("get").description("show a cron s
8273
8570
  });
8274
8571
 
8275
8572
  // src/commands/cron/ls.ts
8276
- import { Command as Command93 } from "commander";
8277
- var lsCommand15 = new Command93("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) => {
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) => {
8278
8575
  const client = await cronClient(cmd);
8279
8576
  try {
8280
8577
  const services = await client.listCronServices({ all: opts.all });
@@ -8294,8 +8591,8 @@ var lsCommand15 = new Command93("ls").alias("list").description("list cron servi
8294
8591
  });
8295
8592
 
8296
8593
  // src/commands/cron/rm.ts
8297
- import { Command as Command94 } from "commander";
8298
- var rmCommand14 = new Command94("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) => {
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) => {
8299
8596
  const client = await cronClient(cmd);
8300
8597
  try {
8301
8598
  if (!await confirm(`Delete cron service ${name}? Its triggers stop firing and their run history is deleted.`, opts.yes ?? false)) {
@@ -8311,14 +8608,14 @@ var rmCommand14 = new Command94("rm").alias("remove").description("delete a cron
8311
8608
  });
8312
8609
 
8313
8610
  // src/commands/cron/trigger/index.ts
8314
- import { Command as Command102 } from "commander";
8611
+ import { Command as Command107 } from "commander";
8315
8612
 
8316
8613
  // src/commands/cron/trigger/add.ts
8317
- import { Command as Command95 } from "commander";
8614
+ import { Command as Command100 } from "commander";
8318
8615
  function portOf(value) {
8319
- const n = Number(value);
8320
- if (!Number.isInteger(n) || n < 1 || n > 65535) throw new KvboxError(`--port ${value}: a port is a number from 1 to 65535`);
8321
- return n;
8616
+ const n2 = Number(value);
8617
+ if (!Number.isInteger(n2) || n2 < 1 || n2 > 65535) throw new KvboxError(`--port ${value}: a port is a number from 1 to 65535`);
8618
+ return n2;
8322
8619
  }
8323
8620
  function methodOf(value) {
8324
8621
  const method = value.toUpperCase();
@@ -8329,12 +8626,12 @@ function timeoutOf(value) {
8329
8626
  const t = value.trim().toLowerCase();
8330
8627
  const units = { s: 1, m: 60, h: 3600 };
8331
8628
  let sec = 0;
8332
- for (const [, n, unit] of t.matchAll(/(\d+)([smh])/g)) sec += Number(n) * units[unit];
8629
+ for (const [, n2, unit] of t.matchAll(/(\d+)([smh])/g)) sec += Number(n2) * units[unit];
8333
8630
  if (!/^(\d+[smh])+$/.test(t) || sec < 1) throw new KvboxError(`--timeout ${value}: give a duration like 90s, 10m or 1h`);
8334
8631
  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`);
8335
8632
  return sec;
8336
8633
  }
8337
- var addCommand3 = new Command95("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) => {
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) => {
8338
8635
  let action;
8339
8636
  if (opts.run !== void 0) {
8340
8637
  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");
@@ -8361,8 +8658,8 @@ var addCommand3 = new Command95("add").description("add a trigger: on a schedule
8361
8658
  });
8362
8659
 
8363
8660
  // src/commands/cron/trigger/ls.ts
8364
- import { Command as Command96 } from "commander";
8365
- var lsCommand16 = new Command96("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) => {
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) => {
8366
8663
  const client = await cronClient(cmd);
8367
8664
  try {
8368
8665
  const triggers = await client.listCronTriggers(service);
@@ -8378,8 +8675,8 @@ var lsCommand16 = new Command96("ls").alias("list").description("list a cron ser
8378
8675
  });
8379
8676
 
8380
8677
  // src/commands/cron/trigger/pause.ts
8381
- import { Command as Command97 } from "commander";
8382
- var pauseCommand2 = new Command97("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) => {
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) => {
8383
8680
  const client = await cronClient(cmd);
8384
8681
  try {
8385
8682
  const trigger = await client.setCronTriggerEnabled(service, id, false);
@@ -8394,8 +8691,8 @@ var pauseCommand2 = new Command97("pause").description("stop a trigger from firi
8394
8691
  });
8395
8692
 
8396
8693
  // src/commands/cron/trigger/resume.ts
8397
- import { Command as Command98 } from "commander";
8398
- var resumeCommand2 = new Command98("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) => {
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) => {
8399
8696
  const client = await cronClient(cmd);
8400
8697
  try {
8401
8698
  const trigger = await client.setCronTriggerEnabled(service, id, true);
@@ -8410,8 +8707,8 @@ var resumeCommand2 = new Command98("resume").description("let a paused trigger f
8410
8707
  });
8411
8708
 
8412
8709
  // src/commands/cron/trigger/rm.ts
8413
- import { Command as Command99 } from "commander";
8414
- var rmCommand15 = new Command99("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) => {
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) => {
8415
8712
  const client = await cronClient(cmd);
8416
8713
  try {
8417
8714
  if (!await confirm(`Delete trigger ${id} of cron service ${service}? Its run history is deleted too.`, opts.yes ?? false)) {
@@ -8427,8 +8724,8 @@ var rmCommand15 = new Command99("rm").alias("remove").description("delete a trig
8427
8724
  });
8428
8725
 
8429
8726
  // src/commands/cron/trigger/run.ts
8430
- import { Command as Command100 } from "commander";
8431
- var runCommand = new Command100("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) => {
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) => {
8432
8729
  const client = await cronClient(cmd);
8433
8730
  try {
8434
8731
  const trigger = await client.runCronTrigger(service, id);
@@ -8444,13 +8741,13 @@ var runCommand = new Command100("run").description("fire a trigger now, once, be
8444
8741
  });
8445
8742
 
8446
8743
  // src/commands/cron/trigger/runs.ts
8447
- import { Command as Command101 } from "commander";
8744
+ import { Command as Command106 } from "commander";
8448
8745
  function limitOf(value) {
8449
- const n = Number(value);
8450
- if (!Number.isInteger(n) || n < 1) throw new KvboxError(`-n ${value}: a number of runs, 1 or more`);
8451
- return n;
8746
+ const n2 = Number(value);
8747
+ if (!Number.isInteger(n2) || n2 < 1) throw new KvboxError(`-n ${value}: a number of runs, 1 or more`);
8748
+ return n2;
8452
8749
  }
8453
- var runsCommand = new Command101("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) => {
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) => {
8454
8751
  const limit = limitOf(opts.limit);
8455
8752
  const client = await cronClient(cmd);
8456
8753
  try {
@@ -8480,24 +8777,24 @@ var runsCommand = new Command101("runs").aliases(["logs"]).description("show how
8480
8777
  });
8481
8778
 
8482
8779
  // src/commands/cron/trigger/index.ts
8483
- var triggerCommand = new Command102("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);
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);
8484
8781
 
8485
8782
  // src/commands/cron/index.ts
8486
- var cronCommand = new Command103("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);
8487
- var withOrg2 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal cron services)");
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);
8784
+ var withOrg3 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal cron services)");
8488
8785
  for (const cmd of cronCommand.commands) {
8489
- if (cmd === triggerCommand) cmd.commands.forEach(withOrg2);
8490
- else withOrg2(cmd);
8786
+ if (cmd === triggerCommand) cmd.commands.forEach(withOrg3);
8787
+ else withOrg3(cmd);
8491
8788
  }
8492
8789
 
8493
8790
  // src/commands/managed/kind.ts
8494
- import { Command as Command122 } from "commander";
8791
+ import { Command as Command127 } from "commander";
8495
8792
 
8496
8793
  // src/commands/managed/backup/index.ts
8497
- import { Command as Command110 } from "commander";
8794
+ import { Command as Command115 } from "commander";
8498
8795
 
8499
8796
  // src/commands/managed/backup/create.ts
8500
- import { Command as Command105 } from "commander";
8797
+ import { Command as Command110 } from "commander";
8501
8798
 
8502
8799
  // src/commands/managed/shared.ts
8503
8800
  import "commander";
@@ -8558,18 +8855,7 @@ function infoRows(spec, m, user) {
8558
8855
  return rows2;
8559
8856
  }
8560
8857
  function scheduleText2(spec, name, s, now = Date.now()) {
8561
- const at = `${String(s.hour).padStart(2, "0")}:00 UTC`;
8562
- if (!s.enabled) return color.dim(`not on their own (kvbox ${spec.command} backup schedule ${name} --on, at ${at})`);
8563
- const nextMs = s.nextAt === null ? null : Date.parse(s.nextAt) - now;
8564
- const next = s.nextAt === null || nextMs === null ? "" : nextMs > -6e4 ? `, next in ${inHours(nextMs)}` : `, ${color.yellow(`due since ${s.nextAt.slice(0, 16).replace("T", " ")} UTC, waiting for the backup job`)}`;
8565
- const failed = s.lastError !== null ? color.yellow(` last one failed: ${s.lastError}`) : "";
8566
- return `daily at ${at}${next}${failed}`;
8567
- }
8568
- function inHours(ms) {
8569
- const min = Math.max(0, Math.round(ms / 6e4));
8570
- if (min < 60) return `${min}m`;
8571
- const h = Math.floor(min / 60);
8572
- return h < 24 ? `${h}h ${min % 60}m` : `${Math.floor(h / 24)}d ${h % 24}h`;
8858
+ return scheduleLine(`kvbox ${spec.command} backup schedule ${name}`, s, now);
8573
8859
  }
8574
8860
  function printRows3(rows2) {
8575
8861
  const width2 = Math.max(...rows2.map(([label]) => label.length));
@@ -8595,7 +8881,7 @@ function parseStorage(text2, flag) {
8595
8881
  }
8596
8882
 
8597
8883
  // src/commands/managed/backup/create.ts
8598
- var createCommand10 = (spec) => new Command105("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) => {
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) => {
8599
8885
  const client = await managedClient(cmd);
8600
8886
  const ls = `kvbox ${spec.command} backup ls ${name}`;
8601
8887
  try {
@@ -8622,7 +8908,7 @@ var createCommand10 = (spec) => new Command105("create").description("back up a
8622
8908
  });
8623
8909
 
8624
8910
  // src/commands/managed/backup/ls.ts
8625
- import { Command as Command106 } from "commander";
8911
+ import { Command as Command111 } from "commander";
8626
8912
  var lsCommand17 = (spec) => {
8627
8913
  const removedOnes = async (err, name, client) => {
8628
8914
  if (!(err instanceof CallError && err.status === 404)) throw err;
@@ -8631,7 +8917,7 @@ var lsCommand17 = (spec) => {
8631
8917
  const own = name.includes("/") ? [] : gone.filter((b) => b.owner === me(client));
8632
8918
  return own.length > 0 ? own : gone;
8633
8919
  };
8634
- return new Command106("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) => {
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) => {
8635
8921
  const client = await managedClient(cmd);
8636
8922
  try {
8637
8923
  const list = name === void 0 ? await client.listManagedBackups(spec.kind) : await client.managedBackups(spec.kind, name).catch((err) => removedOnes(err, name, client));
@@ -8674,8 +8960,8 @@ var lsCommand17 = (spec) => {
8674
8960
  };
8675
8961
 
8676
8962
  // src/commands/managed/backup/restore.ts
8677
- import { Command as Command107 } from "commander";
8678
- var restoreCommand4 = (spec) => new Command107("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) => {
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) => {
8679
8965
  const client = await managedClient(cmd);
8680
8966
  try {
8681
8967
  const backup = await client.managedBackup(spec.kind, name, id);
@@ -8697,8 +8983,8 @@ var restoreCommand4 = (spec) => new Command107("restore").description("put a bac
8697
8983
  });
8698
8984
 
8699
8985
  // src/commands/managed/backup/rm.ts
8700
- import { Command as Command108 } from "commander";
8701
- var rmCommand16 = (spec) => new Command108("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) => {
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) => {
8702
8988
  const client = await managedClient(cmd);
8703
8989
  try {
8704
8990
  await removeListed(client, await client.listManagedBackups(spec.kind), (b) => b.name, name, id, `database ${name}`, opts.yes ?? false);
@@ -8708,51 +8994,37 @@ var rmCommand16 = (spec) => new Command108("rm").alias("remove").description("re
8708
8994
  });
8709
8995
 
8710
8996
  // src/commands/managed/backup/schedule.ts
8711
- import { Command as Command109 } from "commander";
8712
- var scheduleCommand = (spec) => new Command109("schedule").description("show or change when a database is backed up on its own (daily, UTC)").argument("<db>", "its name").option("--at <hour>", "back it up daily at this hour, 0-23 UTC (turns it on)").option("--off", "stop backing it up on its own").option("--on", "back it up on its own again, at the hour it had").option("--json", "print the schedule as JSON").action(async (name, opts, cmd) => {
8713
- if (opts.off && (opts.on || opts.at !== void 0)) throw new KvboxError("--off takes neither --on nor --at");
8714
- const hour = opts.at === void 0 ? void 0 : parseHour(opts.at);
8715
- const client = await managedClient(cmd);
8716
- try {
8717
- const change = { ...opts.off ? { enabled: false } : opts.on ? { enabled: true } : {}, ...hour !== void 0 ? { hour } : {} };
8718
- const changed = Object.keys(change).length > 0;
8719
- const schedule = changed ? await client.setManagedBackupSchedule(spec.kind, name, change) : await client.managedBackupSchedule(spec.kind, name);
8720
- if (opts.json) {
8721
- json(schedule);
8722
- return;
8723
- }
8724
- info(`${changed ? `${color.green("\u2713")} ` : ""}database ${color.bold(name)}: ${scheduleText2(spec, name, schedule)}`);
8725
- if (schedule.lastAt !== null) {
8726
- const last = schedule.lastError !== null ? color.red(`failed: ${schedule.lastError}`) : schedule.lastBackup !== null ? `backup ${schedule.lastBackup}` : "starting a backup";
8727
- info(color.dim(` last turn ${schedule.lastAt.slice(0, 16).replace("T", " ")} UTC: `) + last);
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(
8999
+ async (name, flags, cmd) => {
9000
+ const change = changeOf(flags);
9001
+ const client = await managedClient(cmd);
9002
+ try {
9003
+ const changed = Object.keys(change).length > 0;
9004
+ const schedule = changed ? await client.setManagedBackupSchedule(spec.kind, name, change) : await client.managedBackupSchedule(spec.kind, name);
9005
+ printSchedule(`database ${name}`, `kvbox ${spec.command} backup schedule ${name}`, schedule, flags, changed);
9006
+ } finally {
9007
+ await client.close();
8728
9008
  }
8729
- } finally {
8730
- await client.close();
8731
9009
  }
8732
- });
8733
- function parseHour(text2) {
8734
- const m = /^(\d{1,2})(?::00)?$/.exec(text2.trim());
8735
- const hour = m ? Number(m[1]) : NaN;
8736
- if (!Number.isInteger(hour) || hour < 0 || hour > 23) throw new KvboxError(`--at ${text2}: an hour of the day, 0-23 (UTC), like 3 or 03:00`);
8737
- return hour;
8738
- }
9010
+ );
8739
9011
 
8740
9012
  // src/commands/managed/backup/index.ts
8741
9013
  var backupCommand4 = (spec) => {
8742
- const command = new Command110("backup").description("back up a database to the kvbox cloud, list backups, restore or remove one, or change its nightly schedule");
8743
- for (const make of [createCommand10, lsCommand17, restoreCommand4, rmCommand16, scheduleCommand]) command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
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");
9015
+ for (const make of [createCommand10, lsCommand17, restoreCommand4, rmCommand16, scheduleCommand4]) command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
8744
9016
  return command;
8745
9017
  };
8746
9018
 
8747
9019
  // src/commands/managed/create.ts
8748
- import { Command as Command111 } from "commander";
9020
+ import { Command as Command116 } from "commander";
8749
9021
  import { setTimeout as sleep5 } from "timers/promises";
8750
9022
  var READY_WAIT_MS = 9e4;
8751
9023
  var READY_STEP_MS = 2e3;
8752
9024
  var createCommand11 = (spec) => {
8753
- const command = new Command111("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");
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");
8754
9026
  for (const o of spec.options) command.option(`--${o.name} <${o.arg}>`, o.help);
8755
- 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 the box can be linked to it").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) => {
9027
+ 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) => {
8756
9028
  const options = Object.fromEntries(spec.options.flatMap((o) => typeof opts[o.name] === "string" ? [[o.name, opts[o.name]]] : []));
8757
9029
  const req = {
8758
9030
  name,
@@ -8788,8 +9060,8 @@ var createCommand11 = (spec) => {
8788
9060
  printRows3([...settingRows(spec, made.settings), ...secretRows(made.secret)].map(([label, value]) => [` ${label}`, value]));
8789
9061
  info("");
8790
9062
  info("Nobody can reach it yet. To let something in:");
8791
- info(` a box on the same host kvbox ${spec.command} link ${shown} <box> ${color.dim(`(a new one: kvbox new <box> --near ${shown})`)}`);
8792
- info(` the internet kvbox ${spec.command} public ${shown} on`);
9063
+ info(` a box of yours kvbox ${spec.command} link ${shown} <box> ${color.dim(`(a new one right next to it: kvbox new <box> --near ${shown})`)}`);
9064
+ info(` the internet kvbox ${spec.command} public ${shown} on`);
8793
9065
  info(color.dim(`It costs about ${money(made.price.perMonth, made.price.currency)} a month while it runs, ${money(made.price.storagePerMonth, made.price.currency)} stopped. The password again: kvbox ${spec.command} password ${shown}`));
8794
9066
  if (!ready) info(color.dim(`It was not answering after ${READY_WAIT_MS / 1e3} s; see how it is with: kvbox ${spec.command} info ${shown}`));
8795
9067
  } finally {
@@ -8799,8 +9071,8 @@ var createCommand11 = (spec) => {
8799
9071
  };
8800
9072
 
8801
9073
  // src/commands/managed/grow.ts
8802
- import { Command as Command112 } from "commander";
8803
- var growCommand3 = (spec) => new Command112("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) => {
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) => {
8804
9076
  const storageGib = parseStorage(size, "size");
8805
9077
  const client = await managedClient(cmd);
8806
9078
  try {
@@ -8813,8 +9085,8 @@ var growCommand3 = (spec) => new Command112("grow").description("give a database
8813
9085
  });
8814
9086
 
8815
9087
  // src/commands/managed/info.ts
8816
- import { Command as Command113 } from "commander";
8817
- var infoCommand3 = (spec) => new Command113("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) => {
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) => {
8818
9090
  const client = await managedClient(cmd);
8819
9091
  try {
8820
9092
  const m = await client.getManaged(spec.kind, name);
@@ -8826,8 +9098,8 @@ var infoCommand3 = (spec) => new Command113("info").alias("get").description("sh
8826
9098
  });
8827
9099
 
8828
9100
  // src/commands/managed/link.ts
8829
- import { Command as Command114 } from "commander";
8830
- var linkCommand2 = (spec) => new Command114("link").description("let a box reach a database privately (same host)").argument("<db>", "the database").argument("<box>", "the box that connects to it").option("--json", "print as JSON").action(async (name, box2, opts, cmd) => {
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) => {
8831
9103
  const client = await managedClient(cmd);
8832
9104
  try {
8833
9105
  const m = await spin(`linking ${box2} to ${name}\u2026`, client.linkManaged(spec.kind, name, box2));
@@ -8843,7 +9115,7 @@ var linkCommand2 = (spec) => new Command114("link").description("let a box reach
8843
9115
  });
8844
9116
 
8845
9117
  // src/commands/managed/ls.ts
8846
- import { Command as Command115 } from "commander";
9118
+ import { Command as Command120 } from "commander";
8847
9119
  function listRows(items, user, kindColumn) {
8848
9120
  return items.map((m) => ({
8849
9121
  owner: m.owner === user ? "private" : m.owner,
@@ -8857,7 +9129,7 @@ function listRows(items, user, kindColumn) {
8857
9129
  created: age(m.createdAt)
8858
9130
  }));
8859
9131
  }
8860
- var lsCommand18 = (spec) => new Command115("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) => {
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) => {
8861
9133
  const client = await managedClient(cmd);
8862
9134
  try {
8863
9135
  const items = await client.listManaged(spec?.kind, { all: opts.all });
@@ -8877,8 +9149,8 @@ var lsCommand18 = (spec) => new Command115("ls").alias("list").description(spec
8877
9149
  });
8878
9150
 
8879
9151
  // src/commands/managed/password.ts
8880
- import { Command as Command116 } from "commander";
8881
- var passwordCommand = (spec) => new Command116("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) => {
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) => {
8882
9154
  const client = await managedClient(cmd);
8883
9155
  try {
8884
9156
  const secret = opts.reset ? await spin(`setting a new password on ${name}\u2026`, client.resetManagedPassword(spec.kind, name)) : await client.managedPassword(spec.kind, name);
@@ -8894,8 +9166,8 @@ var passwordCommand = (spec) => new Command116("password").description("show a d
8894
9166
  });
8895
9167
 
8896
9168
  // src/commands/managed/public.ts
8897
- import { Command as Command117 } from "commander";
8898
- var publicCommand2 = (spec) => new Command117("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) => {
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) => {
8899
9171
  if (state !== "on" && state !== "off") throw new KvboxError(`write on or off: kvbox ${spec.command} public ${name} on`);
8900
9172
  const client = await managedClient(cmd);
8901
9173
  try {
@@ -8916,8 +9188,8 @@ var publicCommand2 = (spec) => new Command117("public").description("open a data
8916
9188
  });
8917
9189
 
8918
9190
  // src/commands/managed/rm.ts
8919
- import { Command as Command118 } from "commander";
8920
- var rmCommand17 = (spec) => new Command118("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) => {
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) => {
8921
9193
  const client = await managedClient(cmd);
8922
9194
  try {
8923
9195
  if (!await confirm(`Delete database ${name} and all its data? There is no backup.`, opts.yes ?? false)) {
@@ -8933,8 +9205,8 @@ var rmCommand17 = (spec) => new Command118("rm").alias("remove").description("de
8933
9205
  });
8934
9206
 
8935
9207
  // src/commands/managed/start.ts
8936
- import { Command as Command119 } from "commander";
8937
- var startCommand2 = (spec) => new Command119("start").description("run a stopped database again").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
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) => {
8938
9210
  const client = await managedClient(cmd);
8939
9211
  try {
8940
9212
  const m = await spin(`starting ${name}\u2026`, client.startManaged(spec.kind, name));
@@ -8946,8 +9218,8 @@ var startCommand2 = (spec) => new Command119("start").description("run a stopped
8946
9218
  });
8947
9219
 
8948
9220
  // src/commands/managed/stop.ts
8949
- import { Command as Command120 } from "commander";
8950
- var stopCommand2 = (spec) => new Command120("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) => {
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) => {
8951
9223
  const client = await managedClient(cmd);
8952
9224
  try {
8953
9225
  const m = await spin(`stopping ${name}\u2026`, client.stopManaged(spec.kind, name));
@@ -8959,8 +9231,8 @@ var stopCommand2 = (spec) => new Command120("stop").description("shut a database
8959
9231
  });
8960
9232
 
8961
9233
  // src/commands/managed/unlink.ts
8962
- import { Command as Command121 } from "commander";
8963
- var unlinkCommand2 = (spec) => new Command121("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) => {
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) => {
8964
9236
  const client = await managedClient(cmd);
8965
9237
  try {
8966
9238
  const m = await spin(`unlinking ${box2} from ${name}\u2026`, client.unlinkManaged(spec.kind, name, box2));
@@ -8973,7 +9245,7 @@ var unlinkCommand2 = (spec) => new Command121("unlink").description("stop a box
8973
9245
 
8974
9246
  // src/commands/managed/kind.ts
8975
9247
  function kindCommand(spec, description) {
8976
- const command = new Command122(spec.command).aliases(spec.aliases).description(description);
9248
+ const command = new Command127(spec.command).aliases(spec.aliases).description(description);
8977
9249
  for (const make of [createCommand11, lsCommand18, infoCommand3, passwordCommand, publicCommand2, linkCommand2, unlinkCommand2, growCommand3, stopCommand2, startCommand2, rmCommand17]) {
8978
9250
  command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
8979
9251
  }
@@ -8988,14 +9260,14 @@ var pgCommand = kindCommand(POSTGRES2, "managed PostgreSQL: a database kvbox run
8988
9260
  var redisCommand = kindCommand(REDIS, "managed Redis (Valkey): a Redis kvbox runs for you, private until you link a box or make it public");
8989
9261
 
8990
9262
  // src/commands/managed/index.ts
8991
- import { Command as Command123 } from "commander";
8992
- var managedCommand = new Command123("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)"));
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)"));
8993
9265
 
8994
9266
  // src/commands/env/index.ts
8995
- import { Command as Command127 } from "commander";
9267
+ import { Command as Command132 } from "commander";
8996
9268
 
8997
9269
  // src/commands/env/ls.ts
8998
- import { Command as Command124 } from "commander";
9270
+ import { Command as Command129 } from "commander";
8999
9271
 
9000
9272
  // src/commands/env/shared.ts
9001
9273
  function requireCloud4(client) {
@@ -9022,7 +9294,7 @@ function firstBootHint(box2, name) {
9022
9294
  }
9023
9295
 
9024
9296
  // src/commands/env/ls.ts
9025
- var lsCommand19 = new Command124("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) => {
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) => {
9026
9298
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
9027
9299
  try {
9028
9300
  if (opts.box !== void 0) {
@@ -9061,8 +9333,8 @@ var lsCommand19 = new Command124("ls").alias("list").description("list the varia
9061
9333
  });
9062
9334
 
9063
9335
  // src/commands/env/rm.ts
9064
- import { Command as Command125 } from "commander";
9065
- var rmCommand18 = new Command125("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) => {
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) => {
9066
9338
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
9067
9339
  try {
9068
9340
  const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
@@ -9099,8 +9371,8 @@ var rmCommand18 = new Command125("rm").alias("remove").description("remove varia
9099
9371
  });
9100
9372
 
9101
9373
  // src/commands/env/set.ts
9102
- import { Command as Command126 } from "commander";
9103
- var setCommand2 = new Command126("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) => {
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) => {
9104
9376
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
9105
9377
  try {
9106
9378
  const owner = opts.box === void 0 ? requireCloud4(client) : void 0;
@@ -9137,14 +9409,14 @@ var setCommand2 = new Command126("set").description("add or change a variable; b
9137
9409
  });
9138
9410
 
9139
9411
  // src/commands/env/index.ts
9140
- var envCommand = new Command127("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand19, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand18);
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);
9141
9413
  for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
9142
9414
 
9143
9415
  // src/commands/domain/index.ts
9144
- import { Command as Command131 } from "commander";
9416
+ import { Command as Command136 } from "commander";
9145
9417
 
9146
9418
  // src/commands/domain/add.ts
9147
- import { Command as Command128 } from "commander";
9419
+ import { Command as Command133 } from "commander";
9148
9420
 
9149
9421
  // src/commands/domain/shared.ts
9150
9422
  function requireCloud5(client) {
@@ -9156,15 +9428,15 @@ function domainJson(d, user) {
9156
9428
  }
9157
9429
  function zoneOf(domain) {
9158
9430
  const labels = domain.split(".");
9159
- const n = labels.length > 2 && labels.at(-1).length === 2 && labels.at(-2).length <= 3 ? 3 : 2;
9160
- return labels.slice(-n).join(".");
9431
+ const n2 = labels.length > 2 && labels.at(-1).length === 2 && labels.at(-2).length <= 3 ? 3 : 2;
9432
+ return labels.slice(-n2).join(".");
9161
9433
  }
9162
9434
  function hostIn(name, zone) {
9163
9435
  return name === zone ? "@" : name.endsWith(`.${zone}`) ? name.slice(0, -(zone.length + 1)) : name;
9164
9436
  }
9165
9437
 
9166
9438
  // src/commands/domain/add.ts
9167
- var addCommand4 = new Command128("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) => {
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) => {
9168
9440
  const domain = assertDomain(domainArg.trim().toLowerCase());
9169
9441
  const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
9170
9442
  const client = await clientFor(cmd.optsWithGlobals());
@@ -9200,8 +9472,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
9200
9472
  });
9201
9473
 
9202
9474
  // src/commands/domain/ls.ts
9203
- import { Command as Command129 } from "commander";
9204
- var lsCommand20 = new Command129("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
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) => {
9205
9477
  const client = await clientFor(cmd.optsWithGlobals());
9206
9478
  try {
9207
9479
  requireCloud5(client);
@@ -9230,8 +9502,8 @@ var lsCommand20 = new Command129("ls").alias("list").description("list your cust
9230
9502
  });
9231
9503
 
9232
9504
  // src/commands/domain/rm.ts
9233
- import { Command as Command130 } from "commander";
9234
- var rmCommand19 = new Command130("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) => {
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) => {
9235
9507
  const domain = domainArg.trim().toLowerCase();
9236
9508
  const client = await clientFor(cmd.optsWithGlobals());
9237
9509
  try {
@@ -9252,7 +9524,7 @@ var rmCommand19 = new Command130("rm").alias("remove").description("stop serving
9252
9524
  });
9253
9525
 
9254
9526
  // src/commands/domain/index.ts
9255
- var domainCommand = new Command131("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand4).addCommand(lsCommand20).addCommand(rmCommand19);
9527
+ var domainCommand = new Command136("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand4).addCommand(lsCommand20).addCommand(rmCommand19);
9256
9528
  for (const cmd of domainCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
9257
9529
 
9258
9530
  // src/commands/update.ts
@@ -9260,7 +9532,7 @@ import { spawn as spawn8 } from "child_process";
9260
9532
  import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
9261
9533
  import { tmpdir } from "os";
9262
9534
  import { join as join9 } from "path";
9263
- import { Command as Command132 } from "commander";
9535
+ import { Command as Command137 } from "commander";
9264
9536
 
9265
9537
  // src/update.ts
9266
9538
  import { mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
@@ -9379,7 +9651,7 @@ function run2(cmd, args) {
9379
9651
  child.on("exit", (code, signal) => resolve4(code ?? (signal ? 1 : 0)));
9380
9652
  });
9381
9653
  }
9382
- var selfUpdateCommand = new Command132("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
9654
+ var selfUpdateCommand = new Command137("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
9383
9655
  suppressUpdateNotice();
9384
9656
  const inst = installerFor(process.platform, process.env["KVBOX_INSTALL_URL"] || INSTALL_BASE);
9385
9657
  let code;
@@ -9508,7 +9780,7 @@ function installRootHelp(program) {
9508
9780
 
9509
9781
  // src/program.ts
9510
9782
  function buildProgram() {
9511
- const program = new Command133("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();
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();
9512
9784
  program.addCommand(vmCommand);
9513
9785
  program.addCommand(snapshotsCommand);
9514
9786
  program.addCommand(volumeCommand);