bamboo-agents 0.1.5-dev.13 → 0.1.5-dev.15

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5-dev.13
1
+ 0.1.5-dev.15
package/dist/index.js CHANGED
@@ -3037,7 +3037,7 @@ var VERSION;
3037
3037
  var init_version = __esm({
3038
3038
  "src/version.ts"() {
3039
3039
  "use strict";
3040
- VERSION = "0.1.5-dev.13";
3040
+ VERSION = "0.1.5-dev.15";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -11363,6 +11363,7 @@ var init_auth_token = __esm({
11363
11363
  error: external_exports.enum([
11364
11364
  "unauthorized",
11365
11365
  "no_github_token",
11366
+ "no_active_install",
11366
11367
  "expired",
11367
11368
  "lookup_failed"
11368
11369
  ]),
@@ -11405,6 +11406,24 @@ var init_auth_status = __esm({
11405
11406
  }
11406
11407
  });
11407
11408
 
11409
+ // ../../src/lib/api-contracts/cli/billing-status.ts
11410
+ var BillingStatusResponseSchema;
11411
+ var init_billing_status = __esm({
11412
+ "../../src/lib/api-contracts/cli/billing-status.ts"() {
11413
+ init_zod();
11414
+ BillingStatusResponseSchema = external_exports.object({
11415
+ /** Normalized billing state used by the CLI to decide write-block + copy. */
11416
+ state: external_exports.enum(["trialing", "active", "expired", "unknown"]),
11417
+ /** Whole days remaining on the trial. Only meaningful when state === 'trialing'. */
11418
+ trial_days_remaining: external_exports.number().int().nullable(),
11419
+ /** Best tier name we resolved for the org. Null when no subscription rows exist. */
11420
+ tier_name: external_exports.string().nullable(),
11421
+ /** Where to send the user to upgrade or recover from an expired sub. */
11422
+ billing_url: external_exports.string().url()
11423
+ });
11424
+ }
11425
+ });
11426
+
11408
11427
  // src/lib/api.ts
11409
11428
  import { platform as platform2 } from "node:os";
11410
11429
  function defaultApiBase(version) {
@@ -11453,6 +11472,14 @@ async function getCliAuthStatus(bambooSession) {
11453
11472
  const json = await res.json();
11454
11473
  return AuthStatusResponseSchema.parse(json);
11455
11474
  }
11475
+ async function getCliBillingStatus(bambooSession) {
11476
+ const res = await cliApiFetch(`${apiBase()}/api/cli/billing/status`, {
11477
+ headers: { Authorization: `Bearer ${bambooSession}` }
11478
+ });
11479
+ if (!res.ok) throw await parseError(res);
11480
+ const json = await res.json();
11481
+ return BillingStatusResponseSchema.parse(json);
11482
+ }
11456
11483
  async function startGithubOAuthRelink(bambooSession) {
11457
11484
  const res = await cliApiFetch(
11458
11485
  `${apiBase()}/api/auth/github/oauth-relink/start`,
@@ -11481,6 +11508,7 @@ var init_api = __esm({
11481
11508
  init_zod();
11482
11509
  init_auth_token();
11483
11510
  init_auth_status();
11511
+ init_billing_status();
11484
11512
  init_version();
11485
11513
  PROD_DEFAULT_BASE = "https://withbamboo.com";
11486
11514
  DEV_DEFAULT_BASE = "https://dev.withbamboo.com";
@@ -11617,12 +11645,6 @@ async function handleMissingGithubToken(bambooSession) {
11617
11645
  );
11618
11646
  return null;
11619
11647
  }
11620
- if (err.status === 410) {
11621
- spinner.fail(
11622
- "Your GitHub token expired. Sign in to Bamboo with GitHub again, then re-run."
11623
- );
11624
- return null;
11625
- }
11626
11648
  }
11627
11649
  continue;
11628
11650
  }
@@ -11747,8 +11769,12 @@ async function runLogin() {
11747
11769
  if (!polled) process.exit(1);
11748
11770
  tokenResp = polled;
11749
11771
  } else if (err instanceof ApiError && err.status === 410) {
11750
- tokenSpinner.fail("Your GitHub token expired. Sign in to Bamboo with GitHub again, then re-run.");
11751
- process.exit(1);
11772
+ tokenSpinner.warn(
11773
+ "Your GitHub token expired \u2014 opening browser to refresh authorization\u2026"
11774
+ );
11775
+ const polled = await handleMissingGithubToken(bambooSession);
11776
+ if (!polled) process.exit(1);
11777
+ tokenResp = polled;
11752
11778
  } else {
11753
11779
  tokenSpinner.fail(`Couldn't fetch GitHub token: ${err.message}`);
11754
11780
  process.exit(1);
@@ -12245,6 +12271,22 @@ var status_exports = {};
12245
12271
  __export(status_exports, {
12246
12272
  runStatus: () => runStatus
12247
12273
  });
12274
+ function formatSubscriptionLine(billing) {
12275
+ switch (billing.state) {
12276
+ case "trialing": {
12277
+ const days = billing.trial_days_remaining;
12278
+ const suffix = days === null ? "" : days === 1 ? " (1 day left)" : ` (${days} days left)`;
12279
+ return `Subscription: TRIAL${suffix} \u2014 subscribe at ${billing.billing_url}`;
12280
+ }
12281
+ case "active":
12282
+ return `Subscription: ACTIVE${billing.tier_name ? ` (${billing.tier_name})` : ""}`;
12283
+ case "expired":
12284
+ return `Subscription: EXPIRED \u2014 subscribe at ${billing.billing_url}`;
12285
+ case "unknown":
12286
+ default:
12287
+ return `Subscription: not yet started \u2014 subscribe at ${billing.billing_url}`;
12288
+ }
12289
+ }
12248
12290
  async function runStatus() {
12249
12291
  const creds = await readCredentials();
12250
12292
  const cfg = await readConfig();
@@ -12270,6 +12312,13 @@ async function runStatus() {
12270
12312
  console.log(` Org: ${cfg.org_name}`);
12271
12313
  console.log(` Installed: ${cfg.installed_at}`);
12272
12314
  }
12315
+ if (creds?.bamboo_session) {
12316
+ try {
12317
+ const billing = await getCliBillingStatus(creds.bamboo_session);
12318
+ console.log(` ${formatSubscriptionLine(billing)}`);
12319
+ } catch {
12320
+ }
12321
+ }
12273
12322
  console.log("");
12274
12323
  }
12275
12324
  var init_status = __esm({
@@ -12277,6 +12326,7 @@ var init_status = __esm({
12277
12326
  "use strict";
12278
12327
  init_state();
12279
12328
  init_credentials();
12329
+ init_api();
12280
12330
  }
12281
12331
  });
12282
12332