@birdybeep/cli 0.7.0 → 0.8.0

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.cjs CHANGED
@@ -706,13 +706,12 @@ function createDoctorCommand(deps = {}) {
706
706
  remedy: tokenStoreRemedy(pairing)
707
707
  }
708
708
  );
709
- const reach = (0, import_agent_core4.describeReachability)(
710
- await (0, import_agent_core4.fetchPushReachability)({
711
- baseUrl: apiUrl,
712
- ...deps.tokenOptions ? { tokenOptions: deps.tokenOptions } : {},
713
- ...deps.fetchImpl ? { fetchImpl: deps.fetchImpl } : {}
714
- })
715
- );
709
+ const reachability = await (0, import_agent_core4.fetchPushReachability)({
710
+ baseUrl: apiUrl,
711
+ ...deps.tokenOptions ? { tokenOptions: deps.tokenOptions } : {},
712
+ ...deps.fetchImpl ? { fetchImpl: deps.fetchImpl } : {}
713
+ });
714
+ const reach = (0, import_agent_core4.describeReachability)(reachability);
716
715
  if (reach !== null) {
717
716
  checks.push({
718
717
  name: "Push reachability",
@@ -721,6 +720,19 @@ function createDoctorCommand(deps = {}) {
721
720
  ...reach.remedy !== void 0 ? { remedy: reach.remedy } : {}
722
721
  });
723
722
  }
723
+ const checkIn = (0, import_agent_core4.describeCheckIn)(reachability);
724
+ if (checkIn !== null) {
725
+ checks.push({ name: "Device check-in", ok: checkIn.ok, detail: checkIn.detail });
726
+ }
727
+ const quota = (0, import_agent_core4.describeQuota)(reachability);
728
+ if (quota !== null) {
729
+ checks.push({
730
+ name: "Beep quota",
731
+ ok: quota.ok,
732
+ detail: quota.detail,
733
+ ...quota.remedy !== void 0 ? { remedy: quota.remedy } : {}
734
+ });
735
+ }
724
736
  const unpaired = unpairedActivity();
725
737
  if (unpaired !== null) {
726
738
  checks.push({
@@ -794,6 +806,14 @@ function createDoctorCommand(deps = {}) {
794
806
  checks,
795
807
  pairing,
796
808
  // gcgp.23: paired | unpaired | unknown — never a bare boolean
809
+ // The backend's own quota numbers, unrendered (58l) — a script (or a bug report) gets
810
+ // the window and the counts, not just the sentence built from them.
811
+ ...reachability.state === "ok" && reachability.data.quota !== void 0 ? { quota: reachability.data.quota } : {},
812
+ // The raw check-in (2x9s), unrendered. Present ONLY when the server reported the field
813
+ // at all, so a script can still tell "this backend predates check-ins" (key absent)
814
+ // from "no device has ever checked in" (key present, null) — the same distinction the
815
+ // rendered row is careful about.
816
+ ...reachability.state === "ok" && reachability.data.most_recent_check_in_at !== void 0 ? { mostRecentCheckInAt: reachability.data.most_recent_check_in_at } : {},
797
817
  surfaces: surfaceGroups,
798
818
  queue: { depthBefore, delivered: drain.delivered, depthAfter, overflowDropped },
799
819
  ...unpaired !== null ? { unpairedActivity: unpaired } : {},
@@ -1186,7 +1206,7 @@ async function pairTokenPoll(apiUrl, deviceCode, fetchImpl, machineFingerprint,
1186
1206
  }
1187
1207
 
1188
1208
  // src/version.ts
1189
- var CLI_VERSION = "0.7.0".length > 0 ? "0.7.0" : "0.0.0";
1209
+ var CLI_VERSION = "0.8.0".length > 0 ? "0.8.0" : "0.0.0";
1190
1210
 
1191
1211
  // src/commands/setup.ts
1192
1212
  var import_claude_code5 = require("@birdybeep/claude-code");
@@ -1235,6 +1255,7 @@ function createTestCommand(deps = {}) {
1235
1255
  outcome: result.outcome,
1236
1256
  ...result.status ? { status: result.status } : {},
1237
1257
  ...result.decision ? { decision: result.decision } : {},
1258
+ ...result.queueCause ? { queueCause: result.queueCause } : {},
1238
1259
  ...result.tokenStoreUnavailable !== void 0 ? { tokenStore: "unavailable", tokenStoreReason: result.tokenStoreUnavailable.reason } : {}
1239
1260
  });
1240
1261
  } else if (result.outcome === "delivered") {
@@ -1276,8 +1297,28 @@ function createTestCommand(deps = {}) {
1276
1297
  ctx.io.line(
1277
1298
  `\u2022 Could not read the machine token (${result.tokenStoreUnavailable.reason}) \u2014 the test event was queued and delivers once the token store is readable. If your keychain is locked, unlock it and run \`birdybeep test\` again.`
1278
1299
  );
1300
+ } else if (result.outcome === "queued" && result.queueCause === "backend") {
1301
+ const status = result.status !== void 0 ? ` (HTTP ${String(result.status)})` : "";
1302
+ ctx.io.line(
1303
+ result.code === "rate_limited" || result.status === 429 ? `\u2022 Throttled by the backend${status} \u2014 test event queued; it retries on its own. Not your network: the request got through.` : `\u2022 The backend is having trouble${status} \u2014 test event queued; it retries on its own. Not your network: the request got through.`
1304
+ );
1279
1305
  } else if (result.outcome === "queued") {
1280
1306
  ctx.io.line("\u2022 Offline \u2014 test event queued; it will deliver when you reconnect.");
1307
+ } else if (result.code === "quota_exceeded") {
1308
+ const reach = await (0, import_agent_core8.fetchPushReachability)({
1309
+ baseUrl,
1310
+ ...deps.tokenOptions ? { tokenOptions: deps.tokenOptions } : {},
1311
+ ...deps.fetchImpl ? { fetchImpl: deps.fetchImpl } : {}
1312
+ });
1313
+ const quota = reach.state === "ok" ? reach.data.quota : void 0;
1314
+ const exhausted = quota ? (0, import_agent_core8.describeExhaustedQuota)(quota) : void 0;
1315
+ ctx.io.line(
1316
+ quota && exhausted ? `\u2717 Test event REJECTED \u2014 this account's monthly beep quota is used up (${String(quota.beeps_accepted)}/${String(quota.beeps_limit)} beeps on the ${quota.plan} plan, period ${exhausted.window}). Every notifiable event is being rejected. ${exhausted.remedy}` : (
1317
+ // An older backend reports no quota, so there is no period and no reset date to
1318
+ // give — and `doctor` cannot supply them either, since it reads this same response.
1319
+ "\u2717 Test event REJECTED \u2014 this account's monthly beep quota is used up, so no beep can be sent. This server does not report the period or the reset date; check your usage in the BirdyBeep app."
1320
+ )
1321
+ );
1281
1322
  } else {
1282
1323
  ctx.io.line("\u2717 Test event was rejected by the backend. Run `birdybeep doctor`.");
1283
1324
  }