starkbot-cli 0.1.1 → 0.1.3

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 (2) hide show
  1. package/dist/index.js +42 -51
  2. 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 Subscription"));
445
- if (me.subscription) {
446
- const statusColor2 = me.subscription.status === "active" ? success : warn;
447
- printKeyValue("Status", statusColor2(me.subscription.status));
448
- printKeyValue("Expires", me.subscription.expires_at);
449
- printKeyValue("Days remaining", String(me.subscription.days_remaining));
450
- if (me.subscription.is_expiring_soon) {
451
- console.log(warn(" \u26A0 Subscription expiring soon!"));
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
- } else {
454
- printKeyValue("Status", dim("none"));
455
- console.log(dim(" Run `starkbot subscribe` to get started."));
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);
@@ -591,18 +597,6 @@ async function provisionCommand() {
591
597
  const spin = spinner("Checking instance status...");
592
598
  spin.start();
593
599
  try {
594
- const me = await client.getMe();
595
- if (me.tenant.status === "active" && me.tenant.domain) {
596
- spin.stop();
597
- printSuccess(`Instance already running at ${me.tenant.domain}`);
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.");
604
- return;
605
- }
606
600
  spin.text = "Provisioning your Starkbot instance...";
607
601
  const result = await client.provision();
608
602
  if (result.success) {
@@ -1355,13 +1349,30 @@ __export(wizard_exports, {
1355
1349
  import inquirer4 from "inquirer";
1356
1350
  async function wizardCommand() {
1357
1351
  banner();
1358
- const creds = loadCredentials();
1352
+ let creds = loadCredentials();
1359
1353
  if (!creds || isJwtExpired(creds)) {
1360
1354
  console.log(bold(" Step 1: Login with X\n"));
1361
1355
  await loginCommand();
1362
1356
  console.log();
1363
1357
  } else {
1364
- printSuccess(`Logged in as @${creds.username}`);
1358
+ const { accountAction } = await inquirer4.prompt([
1359
+ {
1360
+ type: "list",
1361
+ name: "accountAction",
1362
+ message: `Logged in as @${creds.username}`,
1363
+ choices: [
1364
+ { name: `Continue as @${creds.username}`, value: "continue" },
1365
+ { name: "Sign out", value: "signout" }
1366
+ ]
1367
+ }
1368
+ ]);
1369
+ if (accountAction === "signout") {
1370
+ await logoutCommand();
1371
+ console.log(bold("\n Login with X\n"));
1372
+ await loginCommand();
1373
+ console.log();
1374
+ creds = loadCredentials();
1375
+ }
1365
1376
  }
1366
1377
  const currentCreds = requireCredentials();
1367
1378
  const client = new FlashClient(currentCreds.jwt);
@@ -1410,7 +1421,7 @@ async function wizardCommand() {
1410
1421
  createSpin.start();
1411
1422
  try {
1412
1423
  me = await client.createInstance(displayName || void 0);
1413
- updateCredentials({ tenant_id: me.tenant.id, gateway_token: void 0, instance_domain: void 0 });
1424
+ updateCredentials({ jwt: me.jwt, tenant_id: me.tenant.id, gateway_token: void 0, instance_domain: void 0 });
1414
1425
  createSpin.succeed("Instance created");
1415
1426
  } catch (err) {
1416
1427
  createSpin.fail("Failed to create instance");
@@ -1422,7 +1433,7 @@ async function wizardCommand() {
1422
1433
  switchSpin.start();
1423
1434
  try {
1424
1435
  me = await client.switchInstance(instanceChoice);
1425
- updateCredentials({ tenant_id: me.tenant.id, gateway_token: void 0, instance_domain: void 0 });
1436
+ updateCredentials({ jwt: me.jwt, tenant_id: me.tenant.id, gateway_token: void 0, instance_domain: void 0 });
1426
1437
  switchSpin.succeed(`Switched to instance ${me.tenant.domain || instanceChoice}`);
1427
1438
  } catch (err) {
1428
1439
  switchSpin.fail("Failed to switch instance");
@@ -1434,29 +1445,9 @@ async function wizardCommand() {
1434
1445
  }
1435
1446
  console.log();
1436
1447
  }
1437
- if (!me.subscription || me.subscription.status !== "active") {
1438
- console.log(bold("\n Subscribe\n"));
1439
- await subscribeCommand();
1440
- try {
1441
- me = await client.getMe();
1442
- } catch {
1443
- return;
1444
- }
1445
- if (!me.subscription || me.subscription.status !== "active") {
1446
- printWarning("Subscription required to continue. Run `starkbot subscribe` when ready.");
1447
- return;
1448
- }
1449
- console.log();
1450
- } else {
1451
- printSuccess(`Subscription active (${me.subscription.days_remaining} days remaining)`);
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}`);
1459
- }
1448
+ console.log(bold("\n Provision your bot\n"));
1449
+ await provisionCommand();
1450
+ console.log();
1460
1451
  const updatedCreds = loadCredentials();
1461
1452
  if (!updatedCreds?.gateway_token || !updatedCreds?.instance_domain) {
1462
1453
  console.log(bold("\n Connect to gateway\n"));
@@ -1488,7 +1479,7 @@ var init_wizard = __esm({
1488
1479
  init_flash_client();
1489
1480
  init_ui();
1490
1481
  init_login();
1491
- init_subscribe();
1482
+ init_logout();
1492
1483
  init_provision();
1493
1484
  init_connect();
1494
1485
  init_chat();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starkbot-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "CLI for Starkbot — login, provision, and chat with your bot from the terminal",
5
5
  "type": "module",
6
6
  "bin": {