@easybits.cloud/cli 0.14.0 → 0.14.1

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.
Files changed (3) hide show
  1. package/README.md +4 -0
  2. package/dist/index.js +108 -105
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -166,6 +166,10 @@ Host *.ghosty
166
166
 
167
167
  Full reference: https://www.easybits.cloud/docs#cli · https://www.easybits.cloud/en/docs/cli.md
168
168
 
169
+ ## Changes in 0.14.1
170
+
171
+ - `machines launch --machine` takes a name too, like every other command.
172
+
169
173
  ## Changes in 0.14.0
170
174
 
171
175
  - `machines launch` (aliases `create`, `new`): create a permanent machine and put an app on it in
package/dist/index.js CHANGED
@@ -1380,6 +1380,108 @@ var sandboxes = {
1380
1380
  // src/commands/machines.ts
1381
1381
  import { existsSync as existsSync6, readFileSync as readFileSync6, statSync as statSync2 } from "fs";
1382
1382
  import { basename as basename2 } from "path";
1383
+
1384
+ // src/refs.ts
1385
+ var ID_FORMAT = {
1386
+ agent: /^[0-9a-f]{24}$/i,
1387
+ db: /^[0-9a-f]{24}$/i,
1388
+ sandbox: /^sb_[0-9a-z-]+$/i
1389
+ };
1390
+ var looksLikeId = (kind, ref) => ID_FORMAT[kind].test(ref);
1391
+ var REF_ARGS = {
1392
+ "agents get": { index: 0, kind: "agent" },
1393
+ "agents message": { index: 0, kind: "agent" },
1394
+ "agents destroy": { index: 0, kind: "agent" },
1395
+ "agents set": { index: 0, kind: "agent" },
1396
+ "agents files": { index: 1, kind: "agent" },
1397
+ "agents skills": { index: 1, kind: "agent" },
1398
+ "agents mcp": { index: 1, kind: "agent" },
1399
+ "agents restart": { index: 0, kind: "agent" },
1400
+ "agents try": { index: 0, kind: "agent" },
1401
+ "agents logs": { index: 0, kind: "agent" },
1402
+ "agents doctor": { index: 0, kind: "agent" },
1403
+ "agents export": { index: 0, kind: "agent" },
1404
+ "sandboxes get": { index: 0, kind: "sandbox" },
1405
+ "sandboxes exec": { index: 0, kind: "sandbox" },
1406
+ "sandboxes logs": { index: 0, kind: "sandbox" },
1407
+ "sandboxes files": { index: 1, kind: "sandbox" },
1408
+ "sandboxes suspend": { index: 0, kind: "sandbox" },
1409
+ "sandboxes resume": { index: 0, kind: "sandbox" },
1410
+ "sandboxes destroy": { index: 0, kind: "sandbox" },
1411
+ "sandboxes snapshot": { index: 0, kind: "sandbox" },
1412
+ "machines deploy": { index: 0, kind: "sandbox" },
1413
+ "machines releases": { index: 0, kind: "sandbox" },
1414
+ "machines logs": { index: 0, kind: "sandbox" },
1415
+ "machines rollback": { index: 0, kind: "sandbox" },
1416
+ "machines secrets": { index: 1, kind: "sandbox" },
1417
+ "domains ls": { index: 0, kind: "sandbox" },
1418
+ "domains add": { index: 0, kind: "sandbox" },
1419
+ "domains verify": { index: 0, kind: "sandbox" },
1420
+ "domains rm": { index: 0, kind: "sandbox" },
1421
+ "db rm": { index: 0, kind: "db" },
1422
+ "db tables": { index: 0, kind: "db" },
1423
+ "db query": { index: 0, kind: "db" },
1424
+ "db photos": { index: 1, kind: "db" }
1425
+ };
1426
+ function matchRef(kind, ref, items) {
1427
+ if (looksLikeId(kind, ref)) return { ok: true, id: ref };
1428
+ const list2 = items ?? [];
1429
+ if (list2.some((x) => x.id === ref)) return { ok: true, id: ref };
1430
+ const want = ref.trim().toLowerCase();
1431
+ const matches = list2.filter((x) => (x.name ?? "").trim().toLowerCase() === want);
1432
+ if (matches.length === 1) return { ok: true, id: matches[0].id };
1433
+ if (matches.length === 0) return { ok: false, reason: "not_found" };
1434
+ return { ok: false, reason: "ambiguous", matches };
1435
+ }
1436
+
1437
+ // src/resolve.ts
1438
+ var LS_HINT = {
1439
+ agent: "easybits agents ls",
1440
+ sandbox: "easybits sandboxes ls",
1441
+ db: "easybits db ls"
1442
+ };
1443
+ var NOUN = () => ({ agent: t("agent", "agente"), sandbox: t("sandbox or machine", "sandbox o m\xE1quina"), db: t("database", "base de datos") });
1444
+ var NOUNS = () => ({ agent: t("agents", "agentes"), sandbox: t("sandboxes", "sandboxes"), db: t("databases", "bases de datos") });
1445
+ var cache = /* @__PURE__ */ new Map();
1446
+ function listRefs(ctx, kind) {
1447
+ let p = cache.get(kind);
1448
+ if (!p) {
1449
+ p = (async () => {
1450
+ const eb = await getClient(ctx);
1451
+ if (kind === "agent") return (await eb.listAgents()).map((a) => ({ id: a.agentId, name: a.name, status: a.status }));
1452
+ if (kind === "db") return (await eb.listDatabases()).items.map((d) => ({ id: d.id, name: d.name }));
1453
+ return (await eb.sandboxes.list()).map((s) => ({ id: s.sandboxId, name: s.name, status: s.status }));
1454
+ })();
1455
+ p.catch(() => cache.delete(kind));
1456
+ cache.set(kind, p);
1457
+ }
1458
+ return p;
1459
+ }
1460
+ async function resolveRef(ctx, kind, ref) {
1461
+ if (looksLikeId(kind, ref)) return ref;
1462
+ const r = matchRef(kind, ref, await listRefs(ctx, kind));
1463
+ if (r.ok) return r.id;
1464
+ if (r.reason === "not_found") {
1465
+ throw new CliError(t(`No ${NOUN()[kind]} with id or name "${ref}".`, `No hay ${NOUN()[kind]} con id o nombre "${ref}".`), EXIT.API, `${t("List them with", "Enl\xEDstalos con")}: ${LS_HINT[kind]}`, "not_found", 404);
1466
+ }
1467
+ const shown = r.matches.slice(0, 10).map((m) => ` ${m.id}${m.status ? ` (${m.status})` : ""}`);
1468
+ if (r.matches.length > 10) shown.push(t(` \u2026and ${r.matches.length - 10} more`, ` \u2026y ${r.matches.length - 10} m\xE1s`));
1469
+ throw new CliError(
1470
+ t(`"${ref}" matches ${r.matches.length} ${NOUNS()[kind]}. Use the id:`, `"${ref}" coincide con ${r.matches.length} ${NOUNS()[kind]}. Usa el id:`),
1471
+ EXIT.USAGE,
1472
+ `${shown.join("\n")}
1473
+ ${t("List them with", "Enl\xEDstalos con")}: ${LS_HINT[kind]}`,
1474
+ "ambiguous"
1475
+ );
1476
+ }
1477
+ async function resolveRefs(ctx, key) {
1478
+ const spec = REF_ARGS[key];
1479
+ const ref = spec ? ctx.args[spec.index] : void 0;
1480
+ if (!spec || !ref) return;
1481
+ ctx.args[spec.index] = await resolveRef(ctx, spec.kind, ref);
1482
+ }
1483
+
1484
+ // src/commands/machines.ts
1383
1485
  var SECRETS_USAGE = "easybits machines secrets <ls|set|unset> <machine> [--dotenv <path> | NAME]";
1384
1486
  var machines = {
1385
1487
  name: "machines",
@@ -1438,15 +1540,16 @@ var machines = {
1438
1540
  async run(ctx) {
1439
1541
  const repo = str(ctx, "repo");
1440
1542
  let archiveUrl = str(ctx, "archive");
1441
- const sandboxId = str(ctx, "machine");
1442
- if (!repo && !archiveUrl && !sandboxId) {
1543
+ const machineRef = str(ctx, "machine");
1544
+ if (!repo && !archiveUrl && !machineRef) {
1443
1545
  throw usageError(t("Give a source: --repo, --archive or --machine.", "Pasa una fuente: --repo, --archive o --machine."), this.usage);
1444
1546
  }
1445
1547
  if (repo && archiveUrl) throw usageError(t("--repo and --archive are exclusive.", "--repo y --archive se excluyen."), this.usage);
1446
- if (sandboxId && str(ctx, "tier")) {
1548
+ if (machineRef && str(ctx, "tier")) {
1447
1549
  throw usageError(t("--tier is only for a new machine (resize = redeploy_machine).", "--tier s\xF3lo aplica a una m\xE1quina nueva (cambiar tama\xF1o = redeploy_machine)."), this.usage);
1448
1550
  }
1449
1551
  const eb = await getClient(ctx);
1552
+ const sandboxId = machineRef ? await resolveRef(ctx, "sandbox", machineRef) : void 0;
1450
1553
  if (archiveUrl && !/^https?:\/\//.test(archiveUrl)) {
1451
1554
  if (!existsSync6(archiveUrl)) throw usageError(t(`File not found: ${archiveUrl}`, `No existe el archivo: ${archiveUrl}`), this.usage);
1452
1555
  const size = statSync2(archiveUrl).size;
@@ -1769,106 +1872,6 @@ function parseLinkStats(columns, row) {
1769
1872
  return columns.map((column, i) => ({ column, permanent: n(i * 4), expiring: n(i * 4 + 1), external: n(i * 4 + 2), empty: n(i * 4 + 3) })).filter((s) => s.permanent + s.expiring + s.external > 0);
1770
1873
  }
1771
1874
 
1772
- // src/refs.ts
1773
- var ID_FORMAT = {
1774
- agent: /^[0-9a-f]{24}$/i,
1775
- db: /^[0-9a-f]{24}$/i,
1776
- sandbox: /^sb_[0-9a-z-]+$/i
1777
- };
1778
- var looksLikeId = (kind, ref) => ID_FORMAT[kind].test(ref);
1779
- var REF_ARGS = {
1780
- "agents get": { index: 0, kind: "agent" },
1781
- "agents message": { index: 0, kind: "agent" },
1782
- "agents destroy": { index: 0, kind: "agent" },
1783
- "agents set": { index: 0, kind: "agent" },
1784
- "agents files": { index: 1, kind: "agent" },
1785
- "agents skills": { index: 1, kind: "agent" },
1786
- "agents mcp": { index: 1, kind: "agent" },
1787
- "agents restart": { index: 0, kind: "agent" },
1788
- "agents try": { index: 0, kind: "agent" },
1789
- "agents logs": { index: 0, kind: "agent" },
1790
- "agents doctor": { index: 0, kind: "agent" },
1791
- "agents export": { index: 0, kind: "agent" },
1792
- "sandboxes get": { index: 0, kind: "sandbox" },
1793
- "sandboxes exec": { index: 0, kind: "sandbox" },
1794
- "sandboxes logs": { index: 0, kind: "sandbox" },
1795
- "sandboxes files": { index: 1, kind: "sandbox" },
1796
- "sandboxes suspend": { index: 0, kind: "sandbox" },
1797
- "sandboxes resume": { index: 0, kind: "sandbox" },
1798
- "sandboxes destroy": { index: 0, kind: "sandbox" },
1799
- "sandboxes snapshot": { index: 0, kind: "sandbox" },
1800
- "machines deploy": { index: 0, kind: "sandbox" },
1801
- "machines releases": { index: 0, kind: "sandbox" },
1802
- "machines logs": { index: 0, kind: "sandbox" },
1803
- "machines rollback": { index: 0, kind: "sandbox" },
1804
- "machines secrets": { index: 1, kind: "sandbox" },
1805
- "domains ls": { index: 0, kind: "sandbox" },
1806
- "domains add": { index: 0, kind: "sandbox" },
1807
- "domains verify": { index: 0, kind: "sandbox" },
1808
- "domains rm": { index: 0, kind: "sandbox" },
1809
- "db rm": { index: 0, kind: "db" },
1810
- "db tables": { index: 0, kind: "db" },
1811
- "db query": { index: 0, kind: "db" },
1812
- "db photos": { index: 1, kind: "db" }
1813
- };
1814
- function matchRef(kind, ref, items) {
1815
- if (looksLikeId(kind, ref)) return { ok: true, id: ref };
1816
- const list2 = items ?? [];
1817
- if (list2.some((x) => x.id === ref)) return { ok: true, id: ref };
1818
- const want = ref.trim().toLowerCase();
1819
- const matches = list2.filter((x) => (x.name ?? "").trim().toLowerCase() === want);
1820
- if (matches.length === 1) return { ok: true, id: matches[0].id };
1821
- if (matches.length === 0) return { ok: false, reason: "not_found" };
1822
- return { ok: false, reason: "ambiguous", matches };
1823
- }
1824
-
1825
- // src/resolve.ts
1826
- var LS_HINT = {
1827
- agent: "easybits agents ls",
1828
- sandbox: "easybits sandboxes ls",
1829
- db: "easybits db ls"
1830
- };
1831
- var NOUN = () => ({ agent: t("agent", "agente"), sandbox: t("sandbox or machine", "sandbox o m\xE1quina"), db: t("database", "base de datos") });
1832
- var NOUNS = () => ({ agent: t("agents", "agentes"), sandbox: t("sandboxes", "sandboxes"), db: t("databases", "bases de datos") });
1833
- var cache = /* @__PURE__ */ new Map();
1834
- function listRefs(ctx, kind) {
1835
- let p = cache.get(kind);
1836
- if (!p) {
1837
- p = (async () => {
1838
- const eb = await getClient(ctx);
1839
- if (kind === "agent") return (await eb.listAgents()).map((a) => ({ id: a.agentId, name: a.name, status: a.status }));
1840
- if (kind === "db") return (await eb.listDatabases()).items.map((d) => ({ id: d.id, name: d.name }));
1841
- return (await eb.sandboxes.list()).map((s) => ({ id: s.sandboxId, name: s.name, status: s.status }));
1842
- })();
1843
- p.catch(() => cache.delete(kind));
1844
- cache.set(kind, p);
1845
- }
1846
- return p;
1847
- }
1848
- async function resolveRef(ctx, kind, ref) {
1849
- if (looksLikeId(kind, ref)) return ref;
1850
- const r = matchRef(kind, ref, await listRefs(ctx, kind));
1851
- if (r.ok) return r.id;
1852
- if (r.reason === "not_found") {
1853
- throw new CliError(t(`No ${NOUN()[kind]} with id or name "${ref}".`, `No hay ${NOUN()[kind]} con id o nombre "${ref}".`), EXIT.API, `${t("List them with", "Enl\xEDstalos con")}: ${LS_HINT[kind]}`, "not_found", 404);
1854
- }
1855
- const shown = r.matches.slice(0, 10).map((m) => ` ${m.id}${m.status ? ` (${m.status})` : ""}`);
1856
- if (r.matches.length > 10) shown.push(t(` \u2026and ${r.matches.length - 10} more`, ` \u2026y ${r.matches.length - 10} m\xE1s`));
1857
- throw new CliError(
1858
- t(`"${ref}" matches ${r.matches.length} ${NOUNS()[kind]}. Use the id:`, `"${ref}" coincide con ${r.matches.length} ${NOUNS()[kind]}. Usa el id:`),
1859
- EXIT.USAGE,
1860
- `${shown.join("\n")}
1861
- ${t("List them with", "Enl\xEDstalos con")}: ${LS_HINT[kind]}`,
1862
- "ambiguous"
1863
- );
1864
- }
1865
- async function resolveRefs(ctx, key) {
1866
- const spec = REF_ARGS[key];
1867
- const ref = spec ? ctx.args[spec.index] : void 0;
1868
- if (!spec || !ref) return;
1869
- ctx.args[spec.index] = await resolveRef(ctx, spec.kind, ref);
1870
- }
1871
-
1872
1875
  // src/commands/db.ts
1873
1876
  async function findDb(ctx, id) {
1874
1877
  const hit = (await listRefs(ctx, "db")).find((d) => d.id === id);
@@ -3489,7 +3492,7 @@ async function updateNotice(current2) {
3489
3492
  }
3490
3493
 
3491
3494
  // src/commands/doctor.ts
3492
- var VERSION = true ? "0.14.0" : "dev";
3495
+ var VERSION = true ? "0.14.1" : "dev";
3493
3496
  var doctor2 = {
3494
3497
  name: "doctor",
3495
3498
  group: "Account",
@@ -3987,7 +3990,7 @@ function normalizeArgs(input) {
3987
3990
  }
3988
3991
 
3989
3992
  // src/index.ts
3990
- var VERSION2 = true ? "0.14.0" : "dev";
3993
+ var VERSION2 = true ? "0.14.1" : "dev";
3991
3994
  var GLOBAL_OPTIONS = {
3992
3995
  json: { type: "boolean" },
3993
3996
  token: { type: "string" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easybits.cloud/cli",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "description": "Official CLI for EasyBits, the cloud for AI agents — sandboxes, hosting, domains, databases, agents and files from your terminal",
5
5
  "type": "module",
6
6
  "bin": {