@kvbox/cli 0.6.13 → 0.6.15
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 +32 -14
- package/dist/kvbox.js.map +1 -1
- package/package.json +1 -1
package/dist/kvbox.js
CHANGED
|
@@ -170,7 +170,7 @@ function versionOf(srcFileUrl, injected) {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
// src/version.ts
|
|
173
|
-
var VERSION = versionOf(import.meta.url, true ? "0.6.
|
|
173
|
+
var VERSION = versionOf(import.meta.url, true ? "0.6.15" : void 0);
|
|
174
174
|
|
|
175
175
|
// src/commands/vm/index.ts
|
|
176
176
|
import { Command as Command39 } from "commander";
|
|
@@ -352,7 +352,7 @@ import { z as z2 } from "zod";
|
|
|
352
352
|
|
|
353
353
|
// ../shared/src/integrations.ts
|
|
354
354
|
import { z } from "zod";
|
|
355
|
-
var INTEGRATION_IDS = ["github"];
|
|
355
|
+
var INTEGRATION_IDS = ["github", "claude"];
|
|
356
356
|
var IntegrationIdSchema = z.enum(INTEGRATION_IDS);
|
|
357
357
|
var INTEGRATION_KINDS = ["oauth", "app", "api-key", "subscription"];
|
|
358
358
|
var IntegrationKindSchema = z.enum(INTEGRATION_KINDS);
|
|
@@ -375,8 +375,11 @@ var IntegrationCatalogEntrySchema = z.object({
|
|
|
375
375
|
id: z.string(),
|
|
376
376
|
title: z.string(),
|
|
377
377
|
description: z.string(),
|
|
378
|
-
/**
|
|
379
|
-
|
|
378
|
+
/**
|
|
379
|
+
* How Connect works: `oauth` sends the browser to the provider's consent screen; `paste` takes a credential
|
|
380
|
+
* 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
|
+
connect: z.string(),
|
|
380
383
|
/** What a user's slug and an org's may hold; an empty list: that kind of slug cannot connect it yet. */
|
|
381
384
|
kinds: z.object({ user: z.array(IntegrationKindSchema), org: z.array(IntegrationKindSchema) }),
|
|
382
385
|
/** Whether this control plane is set up for it (a self-hosted one without a GitHub app is not). */
|
|
@@ -409,6 +412,9 @@ var IntegrationSchema = z.object({
|
|
|
409
412
|
});
|
|
410
413
|
var IntegrationConnectSchema = z.object({ url: z.string() });
|
|
411
414
|
var IntegrationCompleteRequestSchema = z.object({ code: z.string().min(1), state: z.string().min(1) });
|
|
415
|
+
var ClaudeConnectRequestSchema = z.object({
|
|
416
|
+
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
|
+
});
|
|
412
418
|
var IntegrationIdentitySchema = z.object({ name: z.string(), email: z.string() });
|
|
413
419
|
var CREDENTIAL_REFUSALS = ["off", "not-connected", "needs-reconnect", "unavailable"];
|
|
414
420
|
var CredentialAnswerSchema = z.discriminatedUnion("ok", [
|
|
@@ -704,6 +710,11 @@ var MachineSchema = z2.object({
|
|
|
704
710
|
// version of the image the box's overlay stacks on
|
|
705
711
|
/** The image (#87) when it is not the base one: `postgres`. `base` is then that image's version. */
|
|
706
712
|
image: z2.string().optional(),
|
|
713
|
+
/**
|
|
714
|
+
* A newer version of the box's image on its host, the one `kvbox vm update` moves it onto. Only the control
|
|
715
|
+
* plane fills it in (from the host's last `/capacity`); absent while the box is on the newest one, or the host did not say.
|
|
716
|
+
*/
|
|
717
|
+
latestBase: z2.string().optional(),
|
|
707
718
|
createdAt: z2.string(),
|
|
708
719
|
source: z2.string(),
|
|
709
720
|
// "base", "snapshot:<owner/name>", "fork:<owner/name>" (#79) or "backup:<id>" (#141)
|
|
@@ -1025,7 +1036,9 @@ var CapacitySchema = z2.object({
|
|
|
1025
1036
|
/** True on a kvbox-server with `POST /machines/from-backup` (#141, `kvbox new --from-backup`); older ones omit it. */
|
|
1026
1037
|
fromBackup: z2.boolean().optional(),
|
|
1027
1038
|
/** True on a kvbox-server that keeps a box's `integrations` (#205); an older one drops the field without a word. */
|
|
1028
|
-
integrations: z2.boolean().optional()
|
|
1039
|
+
integrations: z2.boolean().optional(),
|
|
1040
|
+
/** The integrations this kvbox-server knows (`hostKnowsIntegrations`). Absent with `integrations`: the first one's, `github` alone. */
|
|
1041
|
+
integrationIds: z2.array(z2.string()).optional()
|
|
1029
1042
|
});
|
|
1030
1043
|
var ImageSchema = z2.object({ name: z2.string(), version: z2.string().nullable() });
|
|
1031
1044
|
var ImageIndexSchema = z2.object({
|
|
@@ -3733,7 +3746,7 @@ async function noteNotConnected(client, box2, asked) {
|
|
|
3733
3746
|
}
|
|
3734
3747
|
|
|
3735
3748
|
// src/commands/vm/new.ts
|
|
3736
|
-
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 (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) => {
|
|
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) => {
|
|
3737
3750
|
const autoHibernateSec = opts.autoHibernate === void 0 ? void 0 : parseIdleTimeout(opts.autoHibernate);
|
|
3738
3751
|
const env = parseEnvFlags(opts.env);
|
|
3739
3752
|
const integrations = opts.integration === void 0 ? void 0 : parseIntegrationList(opts.integration);
|
|
@@ -4112,6 +4125,9 @@ var lsCommand = new Command6("ls").description("list boxes with status and addre
|
|
|
4112
4125
|
}
|
|
4113
4126
|
if (org !== void 0) info(`boxes of ${org}`);
|
|
4114
4127
|
table(lsRows(boxes, cloud ? { me: me(client), showHost: admin } : void 0));
|
|
4128
|
+
const behind = boxes.filter((b) => b.latestBase !== void 0 && b.managed === void 0);
|
|
4129
|
+
const asleep = behind.some((b) => b.status === "hibernated");
|
|
4130
|
+
if (behind.length > 0) info(color.dim(`${behind.length === 1 ? "1 box runs" : `${behind.length} boxes run`} an older image (\u2192 in BASE): kvbox vm update <box> moves it onto the newer one, its files stay${asleep ? " (a hibernated box first: kvbox wake <box>)" : ""}`));
|
|
4115
4131
|
} finally {
|
|
4116
4132
|
await client.close();
|
|
4117
4133
|
}
|
|
@@ -4127,8 +4143,9 @@ function lsRows(boxes, cloud) {
|
|
|
4127
4143
|
address: addressOf(b),
|
|
4128
4144
|
size: b.status === "unknown" ? "-" : `${shape(b.vcpu, b.memMib, b.diskBytes)} ${color.dim(`(${gbShort(b.diskUsedBytes)} used)`)}`,
|
|
4129
4145
|
created: age(b.createdAt),
|
|
4130
|
-
// An image other than the base one (#87) is named: `postgres v0.1.0
|
|
4131
|
-
|
|
4146
|
+
// An image other than the base one (#87) is named: `postgres v0.1.0`; a newer one on the host follows in yellow: `v0.12.0 → v0.16.0`
|
|
4147
|
+
// (not on a managed service's box, which `vm update` cannot reach).
|
|
4148
|
+
base: b.status === "unknown" || b.base === "" ? "-" : `${b.image !== void 0 ? `${b.image} ${b.base}` : b.base}${b.latestBase === void 0 || b.managed !== void 0 ? "" : color.yellow(` \u2192 ${b.latestBase}`)}`
|
|
4132
4149
|
}));
|
|
4133
4150
|
}
|
|
4134
4151
|
|
|
@@ -4213,7 +4230,8 @@ function getRows(box2, subs, user) {
|
|
|
4213
4230
|
if (!box2.autoHibernateSec && box2.idleCheck !== void 0) rows2.push(["idle check", `${box2.idleCheck} ${color.dim("(used once auto-hibernate is on)")}`]);
|
|
4214
4231
|
rows2.push(["integrations", box2.integrations?.length ? box2.integrations.join(", ") : "-"]);
|
|
4215
4232
|
rows2.push(["source", box2.source]);
|
|
4216
|
-
|
|
4233
|
+
const update = box2.latestBase === void 0 ? "" : ` ${color.yellow(`(${box2.latestBase} available: ${box2.status === "hibernated" ? `kvbox wake ${displayName(box2, user)}, then ` : ""}kvbox vm update ${displayName(box2, user)})`)}`;
|
|
4234
|
+
rows2.push(["base", `${box2.image === void 0 ? box2.base : `${box2.image} ${box2.base}`}${update}`]);
|
|
4217
4235
|
rows2.push(["created", `${age(box2.createdAt)} ${color.dim(`(${box2.createdAt})`)}`]);
|
|
4218
4236
|
return rows2;
|
|
4219
4237
|
}
|
|
@@ -5047,7 +5065,7 @@ function runSwap(ep, mib) {
|
|
|
5047
5065
|
}
|
|
5048
5066
|
|
|
5049
5067
|
// src/commands/vm/set.ts
|
|
5050
|
-
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 (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) => {
|
|
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) => {
|
|
5051
5069
|
if (opts.autoHibernate === void 0 && opts.idleCheck === void 0 && opts.integration === void 0 && opts.swap === void 0) {
|
|
5052
5070
|
throw new KvboxError("nothing to change: give --auto-hibernate, --idle-check, --integration or --swap");
|
|
5053
5071
|
}
|
|
@@ -5593,7 +5611,7 @@ import { Command as Command48 } from "commander";
|
|
|
5593
5611
|
|
|
5594
5612
|
// src/commands/integration/ls.ts
|
|
5595
5613
|
import { Command as Command47 } from "commander";
|
|
5596
|
-
var lsCommand6 = new Command47("ls").alias("list").description("list the accounts connected for your boxes (GitHub), per slug; connect one in the web app").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
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) => {
|
|
5597
5615
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
5598
5616
|
try {
|
|
5599
5617
|
if (client.target.kind !== "cloud") throw new KvboxError("integrations belong to an account on the kvbox cloud: kvbox login first");
|
|
@@ -5615,14 +5633,14 @@ var lsCommand6 = new Command47("ls").alias("list").description("list the account
|
|
|
5615
5633
|
}))
|
|
5616
5634
|
);
|
|
5617
5635
|
if (rows2.some((r) => open(r) && (!r.connected || r.status === "needs-reconnect"))) info(color.dim(`connect an account ${whereToConnect(catalog)}`));
|
|
5618
|
-
if (rows2.some((r) => r.connected)) info(color.dim(
|
|
5636
|
+
if (rows2.some((r) => r.connected)) info(color.dim(`turn one on for a box with: kvbox vm set <box> --integration ${rows2.find((r) => r.connected).integration}`));
|
|
5619
5637
|
} finally {
|
|
5620
5638
|
await client.close();
|
|
5621
5639
|
}
|
|
5622
5640
|
});
|
|
5623
5641
|
|
|
5624
5642
|
// src/commands/integration/index.ts
|
|
5625
|
-
var integrationCommand = new Command48("integration").aliases(["integrations"]).description("integrations: accounts (GitHub) connected once in the web app and turned on per box with --integration").addCommand(lsCommand6);
|
|
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);
|
|
5626
5644
|
|
|
5627
5645
|
// src/commands/snapshots/index.ts
|
|
5628
5646
|
import { Command as Command52 } from "commander";
|
|
@@ -9432,7 +9450,7 @@ var HELP_GROUPS = [
|
|
|
9432
9450
|
["managed", "every managed database, whatever its kind"],
|
|
9433
9451
|
["cron", "call a box on a schedule, waking it first if it sleeps"],
|
|
9434
9452
|
["env", "environment variables and secrets every box of yours gets"],
|
|
9435
|
-
["integration", "accounts (GitHub) your boxes use once you turn them on"],
|
|
9453
|
+
["integration", "accounts (GitHub, Claude Code) your boxes use once you turn them on"],
|
|
9436
9454
|
["domain", "serve a box at a domain of your own"]
|
|
9437
9455
|
]
|
|
9438
9456
|
},
|