opencode-pollinations-plugin 6.4.3 → 6.4.4
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/server/quota.js +14 -1
- package/package.json +1 -1
package/dist/server/quota.js
CHANGED
|
@@ -4,6 +4,9 @@ import { loadConfig } from './config.js';
|
|
|
4
4
|
const CACHE_TTL = 30000;
|
|
5
5
|
let cachedQuota = null;
|
|
6
6
|
let lastQuotaFetch = 0;
|
|
7
|
+
const STASH_CACHE_TTL = 5 * 60 * 1000; // 5 min — le stash Quest change rarement
|
|
8
|
+
let cachedStash = null;
|
|
9
|
+
let lastStashFetch = 0;
|
|
7
10
|
const ONE_HOUR_MS = 60 * 60 * 1000;
|
|
8
11
|
const KNOWN_REFILLS = [
|
|
9
12
|
{ pollen: 0, emoji: '👤', label: 'anonymous' },
|
|
@@ -177,11 +180,21 @@ export async function getQuotaStatus(forceRefresh = false) {
|
|
|
177
180
|
const tierNeedsAlert = tierLimit > 0 && tierAlertPercent <= config.thresholds.tier;
|
|
178
181
|
const walletNeedsAlert = cleanWalletBalance > 0 && cleanWalletBalance < (config.thresholds.wallet || 0.5);
|
|
179
182
|
logQuota(`Fetch Success. Allowance: ${allowance}, Paid: ${cleanWalletBalance}, Total: ${totalBalance}`);
|
|
183
|
+
// Fetch quest stash (cached 5 min)
|
|
184
|
+
const nowStash = Date.now();
|
|
185
|
+
if (!cachedStash || (nowStash - lastStashFetch) > STASH_CACHE_TTL) {
|
|
186
|
+
try {
|
|
187
|
+
cachedStash = await fetchQuestStash(config.apiKey);
|
|
188
|
+
lastStashFetch = nowStash;
|
|
189
|
+
}
|
|
190
|
+
catch { /* keep previous */ }
|
|
191
|
+
}
|
|
192
|
+
const questStash = cachedStash?.questStash ?? 0;
|
|
180
193
|
cachedQuota = {
|
|
181
194
|
tierRemaining: cleanTierRemaining,
|
|
182
195
|
tierUsed,
|
|
183
196
|
tierLimit,
|
|
184
|
-
questStash
|
|
197
|
+
questStash,
|
|
185
198
|
walletBalance: cleanWalletBalance,
|
|
186
199
|
nextResetAt: resetInfo.nextReset,
|
|
187
200
|
timeUntilReset: resetInfo.timeUntilReset,
|
package/package.json
CHANGED