starkbot-cli 0.1.1 → 0.1.2
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 +54 -32
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -441,18 +441,24 @@ async function statusCommand() {
|
|
|
441
441
|
printKeyValue("Username", `@${me.user.username}`);
|
|
442
442
|
printKeyValue("Display name", me.user.display_name);
|
|
443
443
|
printKeyValue("Wallet", me.user.wallet_address);
|
|
444
|
-
console.log(bold("\n
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
444
|
+
console.log(bold("\n Credits"));
|
|
445
|
+
const creditBalance = me.credits?.balance ?? 0;
|
|
446
|
+
const formattedCredits = (creditBalance / 1e6).toFixed(2);
|
|
447
|
+
const creditColor = creditBalance > 0 ? success : warn;
|
|
448
|
+
printKeyValue("Balance", creditColor(`$${formattedCredits}`));
|
|
449
|
+
if (me.credits?.last_active_at) {
|
|
450
|
+
const lastActive = new Date(me.credits.last_active_at);
|
|
451
|
+
const daysSinceActive = Math.floor((Date.now() - lastActive.getTime()) / (1e3 * 60 * 60 * 24));
|
|
452
|
+
const lastActiveStr = lastActive.toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" });
|
|
453
|
+
printKeyValue("Last active", `${lastActiveStr} (${daysSinceActive}d ago)`);
|
|
454
|
+
if (daysSinceActive >= 30) {
|
|
455
|
+
console.log(error(" \u26A0 Inactive for 30+ days \u2014 instance will be suspended."));
|
|
456
|
+
} else if (daysSinceActive >= 25) {
|
|
457
|
+
console.log(warn(" \u26A0 Approaching 30-day inactivity limit \u2014 instance may be suspended soon."));
|
|
452
458
|
}
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
console.log(
|
|
459
|
+
}
|
|
460
|
+
if (creditBalance <= 0) {
|
|
461
|
+
console.log(warn(" \u26A0 No credits remaining. Run `starkbot subscribe` to add credits."));
|
|
456
462
|
}
|
|
457
463
|
console.log(bold("\n Active Instance"));
|
|
458
464
|
printKeyValue("ID", me.tenant.id);
|
|
@@ -592,15 +598,11 @@ async function provisionCommand() {
|
|
|
592
598
|
spin.start();
|
|
593
599
|
try {
|
|
594
600
|
const me = await client.getMe();
|
|
595
|
-
|
|
601
|
+
const creditBalance = me.credits?.balance ?? 0;
|
|
602
|
+
const hasSubscription = me.subscription && me.subscription.status === "active";
|
|
603
|
+
if (!hasSubscription && creditBalance <= 0) {
|
|
596
604
|
spin.stop();
|
|
597
|
-
|
|
598
|
-
console.log(dim(` Run \`starkbot connect\` to set up the gateway connection.`));
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
601
|
-
if (!me.subscription || me.subscription.status !== "active") {
|
|
602
|
-
spin.stop();
|
|
603
|
-
printWarning("No active subscription. Run `starkbot subscribe` first.");
|
|
605
|
+
printWarning("No credits available. Run `starkbot subscribe` to add credits first.");
|
|
604
606
|
return;
|
|
605
607
|
}
|
|
606
608
|
spin.text = "Provisioning your Starkbot instance...";
|
|
@@ -1355,13 +1357,30 @@ __export(wizard_exports, {
|
|
|
1355
1357
|
import inquirer4 from "inquirer";
|
|
1356
1358
|
async function wizardCommand() {
|
|
1357
1359
|
banner();
|
|
1358
|
-
|
|
1360
|
+
let creds = loadCredentials();
|
|
1359
1361
|
if (!creds || isJwtExpired(creds)) {
|
|
1360
1362
|
console.log(bold(" Step 1: Login with X\n"));
|
|
1361
1363
|
await loginCommand();
|
|
1362
1364
|
console.log();
|
|
1363
1365
|
} else {
|
|
1364
|
-
|
|
1366
|
+
const { accountAction } = await inquirer4.prompt([
|
|
1367
|
+
{
|
|
1368
|
+
type: "list",
|
|
1369
|
+
name: "accountAction",
|
|
1370
|
+
message: `Logged in as @${creds.username}`,
|
|
1371
|
+
choices: [
|
|
1372
|
+
{ name: `Continue as @${creds.username}`, value: "continue" },
|
|
1373
|
+
{ name: "Sign out", value: "signout" }
|
|
1374
|
+
]
|
|
1375
|
+
}
|
|
1376
|
+
]);
|
|
1377
|
+
if (accountAction === "signout") {
|
|
1378
|
+
await logoutCommand();
|
|
1379
|
+
console.log(bold("\n Login with X\n"));
|
|
1380
|
+
await loginCommand();
|
|
1381
|
+
console.log();
|
|
1382
|
+
creds = loadCredentials();
|
|
1383
|
+
}
|
|
1365
1384
|
}
|
|
1366
1385
|
const currentCreds = requireCredentials();
|
|
1367
1386
|
const client = new FlashClient(currentCreds.jwt);
|
|
@@ -1434,7 +1453,10 @@ async function wizardCommand() {
|
|
|
1434
1453
|
}
|
|
1435
1454
|
console.log();
|
|
1436
1455
|
}
|
|
1437
|
-
|
|
1456
|
+
const creditBalance = me.credits?.balance ?? 0;
|
|
1457
|
+
const hasCredits = creditBalance > 0;
|
|
1458
|
+
const hasSubscription = me.subscription && me.subscription.status === "active";
|
|
1459
|
+
if (!hasCredits && !hasSubscription) {
|
|
1438
1460
|
console.log(bold("\n Subscribe\n"));
|
|
1439
1461
|
await subscribeCommand();
|
|
1440
1462
|
try {
|
|
@@ -1442,21 +1464,20 @@ async function wizardCommand() {
|
|
|
1442
1464
|
} catch {
|
|
1443
1465
|
return;
|
|
1444
1466
|
}
|
|
1445
|
-
|
|
1446
|
-
|
|
1467
|
+
const recheckCredits = me.credits?.balance ?? 0;
|
|
1468
|
+
const recheckSub = me.subscription && me.subscription.status === "active";
|
|
1469
|
+
if (recheckCredits <= 0 && !recheckSub) {
|
|
1470
|
+
printWarning("Credits required to continue. Run `starkbot subscribe` when ready.");
|
|
1447
1471
|
return;
|
|
1448
1472
|
}
|
|
1449
1473
|
console.log();
|
|
1450
1474
|
} else {
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
if (me.tenant.status !== "active" || !me.tenant.domain) {
|
|
1454
|
-
console.log(bold("\n Provision your bot\n"));
|
|
1455
|
-
await provisionCommand();
|
|
1456
|
-
console.log();
|
|
1457
|
-
} else {
|
|
1458
|
-
printSuccess(`Instance running at ${me.tenant.domain}`);
|
|
1475
|
+
const formattedCredits = (creditBalance / 1e6).toFixed(2);
|
|
1476
|
+
printSuccess(`$${formattedCredits} credits available`);
|
|
1459
1477
|
}
|
|
1478
|
+
console.log(bold("\n Provision your bot\n"));
|
|
1479
|
+
await provisionCommand();
|
|
1480
|
+
console.log();
|
|
1460
1481
|
const updatedCreds = loadCredentials();
|
|
1461
1482
|
if (!updatedCreds?.gateway_token || !updatedCreds?.instance_domain) {
|
|
1462
1483
|
console.log(bold("\n Connect to gateway\n"));
|
|
@@ -1488,6 +1509,7 @@ var init_wizard = __esm({
|
|
|
1488
1509
|
init_flash_client();
|
|
1489
1510
|
init_ui();
|
|
1490
1511
|
init_login();
|
|
1512
|
+
init_logout();
|
|
1491
1513
|
init_subscribe();
|
|
1492
1514
|
init_provision();
|
|
1493
1515
|
init_connect();
|