chorus-cli 0.5.0 → 0.5.1
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/README.md +1 -1
- package/index.js +20 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -545,12 +545,31 @@ async function fetchAccountEmail() {
|
|
|
545
545
|
return null;
|
|
546
546
|
}
|
|
547
547
|
|
|
548
|
+
async function fetchCreditBalance(email) {
|
|
549
|
+
if (!email || !CONFIG.ai.chorusApiKey) return null;
|
|
550
|
+
try {
|
|
551
|
+
const baseUrl = CONFIG.ai.chorusApiUrl.replace(/\/v1\/?$/, '');
|
|
552
|
+
const res = await fetch(`${baseUrl}/tokens/balance?email=${encodeURIComponent(email)}&client=true`);
|
|
553
|
+
if (!res.ok) return null;
|
|
554
|
+
const data = await res.json();
|
|
555
|
+
return data.tokenBalance ?? null;
|
|
556
|
+
} catch {
|
|
557
|
+
return null;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
548
561
|
async function printTokenLimitMessage() {
|
|
549
562
|
const email = await fetchAccountEmail();
|
|
550
|
-
const base = 'https://
|
|
563
|
+
const base = 'https://choruscli.com/pricing';
|
|
551
564
|
const url = email ? `${base}?email=${encodeURIComponent(email)}` : base;
|
|
552
565
|
|
|
553
566
|
console.error('\n⚠️ You\'ve run out of Chorus tokens for this month.\n');
|
|
567
|
+
|
|
568
|
+
const balance = await fetchCreditBalance(email);
|
|
569
|
+
if (balance !== null) {
|
|
570
|
+
console.error(` Remaining credit balance: ${balance}\n`);
|
|
571
|
+
}
|
|
572
|
+
|
|
554
573
|
console.error(' To keep going, purchase more tokens at:');
|
|
555
574
|
console.error(` ${url}\n`);
|
|
556
575
|
console.error(' Or wait for your monthly allowance to reset.\n');
|