starkbot-cli 0.1.2 → 0.1.4

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 +21 -55
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -597,14 +597,6 @@ async function provisionCommand() {
597
597
  const spin = spinner("Checking instance status...");
598
598
  spin.start();
599
599
  try {
600
- const me = await client.getMe();
601
- const creditBalance = me.credits?.balance ?? 0;
602
- const hasSubscription = me.subscription && me.subscription.status === "active";
603
- if (!hasSubscription && creditBalance <= 0) {
604
- spin.stop();
605
- printWarning("No credits available. Run `starkbot subscribe` to add credits first.");
606
- return;
607
- }
608
600
  spin.text = "Provisioning your Starkbot instance...";
609
601
  const result = await client.provision();
610
602
  if (result.success) {
@@ -844,28 +836,25 @@ async function connectCommand(opts = {}) {
844
836
  }
845
837
  } catch (err) {
846
838
  spin.fail("Connection failed");
847
- if (err.message?.includes("No CLI gateway token found")) {
848
- printWarning("This instance was provisioned before CLI support \u2014 no gateway token on file.");
849
- console.log(dim(" You can grab your token and domain from the instance dashboard.\n"));
850
- const answers = await inquirer2.prompt([
851
- {
852
- type: "input",
853
- name: "token",
854
- message: "Gateway token:",
855
- validate: (v) => v.trim().length > 0 || "Token is required"
856
- },
857
- {
858
- type: "input",
859
- name: "domain",
860
- message: "Instance domain (e.g. my-bot.starkbot.cloud):",
861
- default: creds.instance_domain || void 0,
862
- validate: (v) => v.trim().length > 0 || "Domain is required"
863
- }
864
- ]);
865
- return connectCommand({ token: answers.token.trim(), domain: answers.domain.trim() });
866
- } else {
867
- printError(err.message);
868
- }
839
+ printWarning("Could not auto-fetch gateway credentials \u2014 you can enter them manually.");
840
+ console.log(dim(` (${err.message})
841
+ `));
842
+ const answers = await inquirer2.prompt([
843
+ {
844
+ type: "input",
845
+ name: "token",
846
+ message: "Gateway token:",
847
+ validate: (v) => v.trim().length > 0 || "Token is required"
848
+ },
849
+ {
850
+ type: "input",
851
+ name: "domain",
852
+ message: "Instance domain (e.g. my-bot.starkbot.cloud):",
853
+ default: creds.instance_domain || void 0,
854
+ validate: (v) => v.trim().length > 0 || "Domain is required"
855
+ }
856
+ ]);
857
+ return connectCommand({ token: answers.token.trim(), domain: answers.domain.trim() });
869
858
  }
870
859
  }
871
860
  var init_connect = __esm({
@@ -1429,7 +1418,7 @@ async function wizardCommand() {
1429
1418
  createSpin.start();
1430
1419
  try {
1431
1420
  me = await client.createInstance(displayName || void 0);
1432
- updateCredentials({ tenant_id: me.tenant.id, gateway_token: void 0, instance_domain: void 0 });
1421
+ updateCredentials({ jwt: me.jwt, tenant_id: me.tenant.id, gateway_token: void 0, instance_domain: void 0 });
1433
1422
  createSpin.succeed("Instance created");
1434
1423
  } catch (err) {
1435
1424
  createSpin.fail("Failed to create instance");
@@ -1441,7 +1430,7 @@ async function wizardCommand() {
1441
1430
  switchSpin.start();
1442
1431
  try {
1443
1432
  me = await client.switchInstance(instanceChoice);
1444
- updateCredentials({ tenant_id: me.tenant.id, gateway_token: void 0, instance_domain: void 0 });
1433
+ updateCredentials({ jwt: me.jwt, tenant_id: me.tenant.id, gateway_token: void 0, instance_domain: void 0 });
1445
1434
  switchSpin.succeed(`Switched to instance ${me.tenant.domain || instanceChoice}`);
1446
1435
  } catch (err) {
1447
1436
  switchSpin.fail("Failed to switch instance");
@@ -1453,28 +1442,6 @@ async function wizardCommand() {
1453
1442
  }
1454
1443
  console.log();
1455
1444
  }
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) {
1460
- console.log(bold("\n Subscribe\n"));
1461
- await subscribeCommand();
1462
- try {
1463
- me = await client.getMe();
1464
- } catch {
1465
- return;
1466
- }
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.");
1471
- return;
1472
- }
1473
- console.log();
1474
- } else {
1475
- const formattedCredits = (creditBalance / 1e6).toFixed(2);
1476
- printSuccess(`$${formattedCredits} credits available`);
1477
- }
1478
1445
  console.log(bold("\n Provision your bot\n"));
1479
1446
  await provisionCommand();
1480
1447
  console.log();
@@ -1510,7 +1477,6 @@ var init_wizard = __esm({
1510
1477
  init_ui();
1511
1478
  init_login();
1512
1479
  init_logout();
1513
- init_subscribe();
1514
1480
  init_provision();
1515
1481
  init_connect();
1516
1482
  init_chat();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starkbot-cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "CLI for Starkbot — login, provision, and chat with your bot from the terminal",
5
5
  "type": "module",
6
6
  "bin": {