rampup 0.1.9 ā 0.1.11
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/index.js +102 -32
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1126,8 +1126,19 @@ Be friendly, practical, and reference specific files when relevant. If asked abo
|
|
|
1126
1126
|
|
|
1127
1127
|
console.log(chalk.cyan('\nš Ending voice session...'));
|
|
1128
1128
|
console.log(chalk.dim(`Session: ${totalSessionMinutes.toFixed(2)} min`));
|
|
1129
|
-
console.log(chalk.dim(`Total usage: ${usage.totalMinutes.toFixed(2)} min\n`));
|
|
1130
1129
|
|
|
1130
|
+
// Show credits used and remaining
|
|
1131
|
+
try {
|
|
1132
|
+
const balance = await getTokenBalance();
|
|
1133
|
+
if (balance?.balances?.[0]) {
|
|
1134
|
+
const credits = balance.balances[0];
|
|
1135
|
+
const creditsUsed = Math.max(2, Math.ceil(totalSessionMinutes * 4));
|
|
1136
|
+
console.log(chalk.dim(`Credits used: ${creditsUsed}`));
|
|
1137
|
+
console.log(chalk.cyan(`Credits remaining: ${credits.balance}`));
|
|
1138
|
+
}
|
|
1139
|
+
} catch {}
|
|
1140
|
+
|
|
1141
|
+
console.log();
|
|
1131
1142
|
process.exit(0);
|
|
1132
1143
|
}
|
|
1133
1144
|
|
|
@@ -1386,47 +1397,106 @@ program
|
|
|
1386
1397
|
console.log(banner);
|
|
1387
1398
|
console.log(chalk.bold.blue('ā” Upgrade Plan\n'));
|
|
1388
1399
|
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1400
|
+
const ENTITLEMENT_API_URL = process.env.ENTITLEMENT_API_URL ||
|
|
1401
|
+
'https://entitlement-service.rian-19c.workers.dev';
|
|
1402
|
+
|
|
1403
|
+
// Check if user is logged in
|
|
1404
|
+
const token = await getIdToken();
|
|
1405
|
+
if (!token) {
|
|
1406
|
+
console.log(chalk.yellow('Please log in first to upgrade your plan.\n'));
|
|
1407
|
+
console.log(chalk.dim('Run: ramp login\n'));
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
const spinner = ora('Loading plans...').start();
|
|
1412
|
+
|
|
1392
1413
|
try {
|
|
1393
|
-
|
|
1394
|
-
|
|
1414
|
+
// Get current balance
|
|
1415
|
+
const balance = await getTokenBalance();
|
|
1416
|
+
const currentCredits = balance?.balances?.[0]?.balance || 0;
|
|
1395
1417
|
|
|
1396
|
-
|
|
1397
|
-
|
|
1418
|
+
// Fetch plans from API
|
|
1419
|
+
const plansResponse = await fetch(`${ENTITLEMENT_API_URL}/billing/ramp/plans`);
|
|
1420
|
+
if (!plansResponse.ok) {
|
|
1421
|
+
throw new Error('Failed to fetch plans');
|
|
1422
|
+
}
|
|
1423
|
+
const { plans } = await plansResponse.json();
|
|
1398
1424
|
|
|
1399
|
-
|
|
1425
|
+
spinner.succeed('Plans loaded!\n');
|
|
1400
1426
|
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
console.log(chalk.dim(' ⢠Unlimited text queries'));
|
|
1404
|
-
console.log(chalk.dim(' ⢠5 team members\n'));
|
|
1427
|
+
// Show current balance
|
|
1428
|
+
console.log(chalk.bold('Current Balance:'), chalk.cyan(`${currentCredits} credits\n`));
|
|
1405
1429
|
|
|
1406
|
-
|
|
1407
|
-
console.log(chalk.dim(' ⢠500 voice minutes'));
|
|
1408
|
-
console.log(chalk.dim(' ⢠Unlimited everything'));
|
|
1409
|
-
console.log(chalk.dim(' ⢠25 team members'));
|
|
1410
|
-
console.log(chalk.dim(' ⢠Priority support\n'));
|
|
1430
|
+
console.log(chalk.bold('Available Plans:\n'));
|
|
1411
1431
|
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1432
|
+
// Display plans
|
|
1433
|
+
for (const plan of plans) {
|
|
1434
|
+
const priceStr = plan.price === 0 ? 'Free' : `$${plan.price}/mo`;
|
|
1435
|
+
const label = plan.popular ? `${plan.name} ā` : plan.name;
|
|
1436
|
+
console.log(chalk.cyan(` ${label} - ${priceStr}`));
|
|
1437
|
+
for (const feature of plan.features) {
|
|
1438
|
+
console.log(chalk.dim(` ⢠${feature}`));
|
|
1439
|
+
}
|
|
1440
|
+
console.log();
|
|
1441
|
+
}
|
|
1417
1442
|
|
|
1418
|
-
|
|
1443
|
+
// Get paid plans for selection
|
|
1444
|
+
const paidPlans = plans.filter(p => p.price > 0);
|
|
1419
1445
|
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1446
|
+
const { selectedPlan } = await inquirer.prompt([{
|
|
1447
|
+
type: 'list',
|
|
1448
|
+
name: 'selectedPlan',
|
|
1449
|
+
message: 'Select a plan to upgrade:',
|
|
1450
|
+
choices: [
|
|
1451
|
+
...paidPlans.map(p => ({
|
|
1452
|
+
name: `${p.name} ($${p.price}/mo) - ${p.credits} credits`,
|
|
1453
|
+
value: p.id
|
|
1454
|
+
})),
|
|
1455
|
+
{ name: 'Cancel', value: null }
|
|
1456
|
+
]
|
|
1457
|
+
}]);
|
|
1458
|
+
|
|
1459
|
+
if (!selectedPlan) {
|
|
1460
|
+
console.log(chalk.dim('\nNo plan selected.\n'));
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
// Create checkout session
|
|
1465
|
+
const checkoutSpinner = ora('Creating checkout session...').start();
|
|
1466
|
+
|
|
1467
|
+
const checkoutResponse = await fetch(`${ENTITLEMENT_API_URL}/billing/ramp/checkout`, {
|
|
1468
|
+
method: 'POST',
|
|
1469
|
+
headers: {
|
|
1470
|
+
'Authorization': `Bearer ${token}`,
|
|
1471
|
+
'Content-Type': 'application/json'
|
|
1472
|
+
},
|
|
1473
|
+
body: JSON.stringify({
|
|
1474
|
+
plan: selectedPlan,
|
|
1475
|
+
successUrl: 'https://rampup.dev/billing?checkout=success',
|
|
1476
|
+
cancelUrl: 'https://rampup.dev/pricing?checkout=cancelled'
|
|
1477
|
+
})
|
|
1478
|
+
});
|
|
1479
|
+
|
|
1480
|
+
if (!checkoutResponse.ok) {
|
|
1481
|
+
const error = await checkoutResponse.json().catch(() => ({}));
|
|
1482
|
+
throw new Error(error.message || 'Failed to create checkout session');
|
|
1483
|
+
}
|
|
1426
1484
|
|
|
1427
|
-
|
|
1485
|
+
const { url } = await checkoutResponse.json();
|
|
1486
|
+
checkoutSpinner.succeed('Checkout ready!\n');
|
|
1487
|
+
|
|
1488
|
+
console.log(chalk.green('Opening Stripe checkout in your browser...\n'));
|
|
1428
1489
|
const open = (await import('open')).default;
|
|
1429
|
-
await open(
|
|
1490
|
+
await open(url);
|
|
1491
|
+
|
|
1492
|
+
console.log(chalk.dim('If browser doesn\'t open, visit:'));
|
|
1493
|
+
console.log(chalk.cyan(url));
|
|
1494
|
+
console.log();
|
|
1495
|
+
|
|
1496
|
+
} catch (error) {
|
|
1497
|
+
spinner.fail('Failed to load upgrade options');
|
|
1498
|
+
console.error(chalk.red(error.message));
|
|
1499
|
+
console.log(chalk.dim('\nYou can also upgrade at: https://rampup.dev/pricing\n'));
|
|
1430
1500
|
}
|
|
1431
1501
|
});
|
|
1432
1502
|
|