@easybits.cloud/cli 0.5.0 → 0.5.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.
- package/dist/index.js +20 -7
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -41,17 +41,28 @@ function notLoggedIn() {
|
|
|
41
41
|
function apiMessage(body) {
|
|
42
42
|
try {
|
|
43
43
|
const j = JSON.parse(body);
|
|
44
|
+
if (typeof j.error === "string" && typeof j.message === "string") return { message: `${j.error}: ${j.message}`, kind: j.error };
|
|
45
|
+
if (typeof j.code === "string" && typeof j.error === "string") return { message: `${j.code}: ${j.error}`, kind: j.code };
|
|
44
46
|
const msg = j.message ?? j.error ?? j.detail;
|
|
45
|
-
if (typeof msg === "string") return msg;
|
|
46
|
-
if (msg) return JSON.stringify(msg);
|
|
47
|
+
if (typeof msg === "string") return { message: msg };
|
|
48
|
+
if (msg) return { message: JSON.stringify(msg) };
|
|
47
49
|
} catch {
|
|
48
50
|
}
|
|
49
|
-
return body.trim() || "empty response";
|
|
51
|
+
return { message: body.trim() || "empty response" };
|
|
50
52
|
}
|
|
53
|
+
var KIND_HINTS = {
|
|
54
|
+
SandboxBusy: "A snapshot or fork is running on this sandbox. Wait a few minutes and retry (easybits sb get <id> shows `activity`).",
|
|
55
|
+
SandboxUnreachable: "The sandbox is not answering inside. Wait and retry; if it persists, destroy it.",
|
|
56
|
+
SandboxHostTimeout: "The operation may still be running. Check `easybits sb get <id>` and retry in a few minutes.",
|
|
57
|
+
SandboxHostError: "The sandbox host failed. Retry; if it persists, contact support.",
|
|
58
|
+
SQL_ERROR: "Fix the SQL statement.",
|
|
59
|
+
DATABASE_STORAGE_MISSING: "This database has no storage; its data is unavailable. Delete it (easybits db rm) and create a new one.",
|
|
60
|
+
DATABASE_BACKEND_ERROR: "The database backend failed. Retry in a moment."
|
|
61
|
+
};
|
|
51
62
|
function toCliError(err) {
|
|
52
63
|
if (err instanceof CliError) return err;
|
|
53
64
|
if (err instanceof EasybitsError) {
|
|
54
|
-
const message2 = apiMessage(err.body);
|
|
65
|
+
const { message: message2, kind } = apiMessage(err.body);
|
|
55
66
|
if (err.status === 401) {
|
|
56
67
|
return new CliError(
|
|
57
68
|
`Credentials rejected (401): ${message2}`,
|
|
@@ -61,7 +72,7 @@ function toCliError(err) {
|
|
|
61
72
|
401
|
|
62
73
|
);
|
|
63
74
|
}
|
|
64
|
-
const hint = err.status === 403 ? "Your key may lack the scope for this action (READ/WRITE/DELETE)." : err.status === 404 ? "Check the id. List what you have with the matching `ls` command." : err.status === 402 ? "Plan limit reached. See: easybits usage" : void 0;
|
|
75
|
+
const hint = (kind && KIND_HINTS[kind]) ?? (err.status === 403 ? "Your key may lack the scope for this action (READ/WRITE/DELETE)." : err.status === 404 ? "Check the id. List what you have with the matching `ls` command." : err.status === 402 ? "Plan limit reached. See: easybits usage" : void 0);
|
|
65
76
|
return new CliError(`API error ${err.status}: ${message2}`, EXIT.API, hint, "api_error", err.status);
|
|
66
77
|
}
|
|
67
78
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -883,7 +894,8 @@ function sandboxRecord(s) {
|
|
|
883
894
|
tier: s.tier,
|
|
884
895
|
cpuMode: s.cpuMode,
|
|
885
896
|
monthlyMxn: s.monthlyMxn,
|
|
886
|
-
metadata: s.metadata
|
|
897
|
+
metadata: s.metadata,
|
|
898
|
+
activity: s.activity
|
|
887
899
|
};
|
|
888
900
|
}
|
|
889
901
|
function printSandbox(s) {
|
|
@@ -891,6 +903,7 @@ function printSandbox(s) {
|
|
|
891
903
|
if (s.name) console.log(`Name: ${s.name}`);
|
|
892
904
|
console.log(`Template: ${s.template}`);
|
|
893
905
|
console.log(`Status: ${s.status}`);
|
|
906
|
+
if (s.activity) console.log(`Activity: ${s.activity} (busy: exec/suspend/destroy answer 409 SandboxBusy until it ends)`);
|
|
894
907
|
console.log(`Created: ${fmtDate(s.createdAt)}`);
|
|
895
908
|
console.log(`Expires: ${s.persistent ? "never (permanent)" : fmtDate(s.expiresAt)}`);
|
|
896
909
|
if (s.tier) console.log(`Tier: ${s.tier}${s.monthlyMxn != null ? ` ($${s.monthlyMxn} MXN/month)` : ""}`);
|
|
@@ -1636,7 +1649,7 @@ var BANNER = " \x1B[38;2;244;245;251m\u2860\u2812\u2812\u28E4\x1B[38;
|
|
|
1636
1649
|
|
|
1637
1650
|
// src/index.ts
|
|
1638
1651
|
import { EasybitsError as EasybitsError2 } from "@easybits.cloud/sdk";
|
|
1639
|
-
var VERSION = true ? "0.5.
|
|
1652
|
+
var VERSION = true ? "0.5.1" : "dev";
|
|
1640
1653
|
var GLOBAL_OPTIONS = {
|
|
1641
1654
|
json: { type: "boolean" },
|
|
1642
1655
|
token: { type: "string" },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easybits.cloud/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.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": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@easybits.cloud/sdk": "^0.35.
|
|
38
|
+
"@easybits.cloud/sdk": "^0.35.3"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^22.0.0",
|