MCPcopy Index your code
hub / github.com/Microck/opencode-studio / getPoolQuota

Function getPoolQuota

server/index.js:3664–3693  ·  view source on GitHub ↗
(provider, pool)

Source from the content-addressed store, hash-verified

3662}
3663
3664function getPoolQuota(provider, pool) {
3665 const metadata = loadPoolMetadata();
3666 const activePlugin = getActiveGooglePlugin();
3667 const namespace = provider === 'google'
3668 ? ('google.antigravity')
3669 : provider;
3670
3671 const quotaMeta = metadata._quota?.[namespace] || {};
3672 const today = new Date().toISOString().split('T')[0];
3673 const todayUsage = quotaMeta[today] || 0;
3674
3675 // Estimate: 1000 requests/day limit (configurable)
3676 const dailyLimit = quotaMeta.dailyLimit || 1000;
3677 const remaining = Math.max(0, dailyLimit - todayUsage);
3678 const percentage = Math.round((remaining / dailyLimit) * 100);
3679
3680 return {
3681 dailyLimit,
3682 remaining,
3683 used: todayUsage,
3684 percentage,
3685 resetAt: new Date(new Date().setHours(24, 0, 0, 0)).toISOString(),
3686 byAccount: pool.accounts.map(acc => ({
3687 name: acc.name,
3688 email: acc.email,
3689 used: acc.usageCount,
3690 limit: Math.floor(dailyLimit / Math.max(1, pool.totalAccounts))
3691 }))
3692 };
3693}
3694
3695function rotateAccount(provider, reason = 'manual_rotation') {
3696 const pool = buildAccountPool(provider);

Callers 1

index.jsFile · 0.85

Calls 2

loadPoolMetadataFunction · 0.85
getActiveGooglePluginFunction · 0.70

Tested by

no test coverage detected