@kvbox/cli 0.6.4 → 0.6.6

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
@@ -164,7 +164,7 @@ function versionOf(srcFileUrl, injected) {
164
164
  }
165
165
 
166
166
  // src/version.ts
167
- var VERSION = versionOf(import.meta.url, true ? "0.6.4" : void 0);
167
+ var VERSION = versionOf(import.meta.url, true ? "0.6.6" : void 0);
168
168
 
169
169
  // src/commands/vm/index.ts
170
170
  import { Command as Command37 } from "commander";
@@ -686,7 +686,12 @@ var BoxRunSchema = z.object({
686
686
  id: z.string(),
687
687
  state: z.enum(BOX_RUN_STATES),
688
688
  /** With `exited`; 128 + the signal for a command a signal ended. */
689
- exitCode: z.number().int().optional()
689
+ exitCode: z.number().int().optional(),
690
+ /**
691
+ * With `exited` and `timeout`: how long the command itself ran, by the box's own clock (base v0.15.1
692
+ * and later). The asker learns of the end seconds late, so its own count is too long.
693
+ */
694
+ durationMs: z.number().int().nonnegative().optional()
690
695
  });
691
696
  var RunRefusalSchema = z.object({ error: z.string(), code: z.string().optional() });
692
697
  var EnvVarSchema = z.object({
@@ -1886,7 +1891,7 @@ async function resolveTarget(opts, p = paths()) {
1886
1891
  const session = await readSession(p);
1887
1892
  if (session) return { kind: "cloud", url: session.url, token: session.token, user: session.user, ...org === void 0 ? {} : { org } };
1888
1893
  }
1889
- return { kind: "local", socketPath: p.serverSock };
1894
+ return { kind: "local", socketPath: p.serverSock, ...opts.local ? {} : { noLogin: true } };
1890
1895
  }
1891
1896
  var allQuery = (opts) => opts.all ? "?all=1" : "";
1892
1897
  var ServerClient = class {
@@ -1925,7 +1930,10 @@ var ServerClient = class {
1925
1930
  if (this.target.kind === "local") {
1926
1931
  if (this.autoStart && !this.startedOnce) {
1927
1932
  this.startedOnce = true;
1928
- await spin("starting kvbox-server\u2026", startLocalServer(paths(), 5e3));
1933
+ const { noLogin } = this.target;
1934
+ await spin("starting kvbox-server\u2026", startLocalServer(paths(), 5e3)).catch((err2) => {
1935
+ throw noLogin && err2 instanceof KvboxError && err2.message === NOT_A_HOST_HINT ? new KvboxError(NOT_LOGGED_IN) : err2;
1936
+ });
1929
1937
  return this.call(method, path, schema, body, org, timeoutMs);
1930
1938
  }
1931
1939
  throw new KvboxError(`kvbox-server is not running (${String(code)}); start it with: kvbox-server start -d`);
@@ -2443,6 +2451,7 @@ async function checkDirect(ep) {
2443
2451
  throw new KvboxError(`--direct: cannot reach ${ep.host}:${ep.port}; it works only on the box's host (leave it out to go through the public address)`);
2444
2452
  });
2445
2453
  }
2454
+ var NOT_LOGGED_IN = "you are not logged in. Run: kvbox login";
2446
2455
  var NOT_A_HOST_HINT = "kvbox-server is not installed, so this machine is not a kvbox host. Set it up with install-server.sh, or log in to the cloud with: kvbox login";
2447
2456
  async function lastErrorLine(logPath, from = 0) {
2448
2457
  const { readFile: readFile8 } = await import("fs/promises");
@@ -4556,17 +4565,17 @@ import { Command as Command54 } from "commander";
4556
4565
  import { Command as Command49 } from "commander";
4557
4566
 
4558
4567
  // src/commands/org/context.ts
4559
- var NOT_LOGGED_IN = "orgs live on the control plane: kvbox login first";
4568
+ var NOT_LOGGED_IN2 = "orgs live on the control plane: kvbox login first";
4560
4569
  async function cloudClientFor(opts) {
4561
4570
  const client = await clientFor(opts, { autoStart: false });
4562
4571
  if (client.target.kind === "local") {
4563
4572
  await client.close();
4564
- throw new KvboxError(NOT_LOGGED_IN);
4573
+ throw new KvboxError(NOT_LOGGED_IN2);
4565
4574
  }
4566
4575
  return client;
4567
4576
  }
4568
4577
  function orgFor(opts, target) {
4569
- if (target.kind === "local") throw new KvboxError(NOT_LOGGED_IN);
4578
+ if (target.kind === "local") throw new KvboxError(NOT_LOGGED_IN2);
4570
4579
  const slug = opts.org ?? target.org;
4571
4580
  if (slug === void 0) throw new KvboxError("no org: pass --org <slug>");
4572
4581
  return slug;