opencode-pollinations-plugin 5.5.3 → 5.5.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.
@@ -5,37 +5,34 @@ import { getDetailedUsage } from './pollinations-api.js';
5
5
  import { generatePollinationsConfig } from './generate-config.js';
6
6
  import * as https from 'https';
7
7
  // --- HELPER: STRICT PERMISSION CHECK ---
8
- function checkKeyPermissions(key) {
8
+ function checkEndpoint(ep, key) {
9
9
  return new Promise((resolve) => {
10
- // We need Usage, Profile AND Balance for "Managed Modes"
11
- // If any of these fail (403), the key is Limited.
12
- const endpoints = ['/account/profile', '/account/balance', '/account/usage'];
13
- let successCount = 0;
14
- let completed = 0;
15
- endpoints.forEach(ep => {
16
- const req = https.request({
17
- hostname: 'gen.pollinations.ai',
18
- path: ep,
19
- method: 'GET',
20
- headers: { 'Authorization': `Bearer ${key}` }
21
- }, (res) => {
22
- completed++;
23
- if (res.statusCode === 200)
24
- successCount++;
25
- if (completed === endpoints.length) {
26
- resolve(successCount === endpoints.length);
27
- }
28
- });
29
- req.on('error', () => {
30
- completed++;
31
- if (completed === endpoints.length)
32
- resolve(successCount === endpoints.length);
33
- });
34
- req.setTimeout(5000, () => req.destroy());
35
- req.end();
10
+ const req = https.request({
11
+ hostname: 'gen.pollinations.ai',
12
+ path: ep,
13
+ method: 'GET',
14
+ headers: { 'Authorization': `Bearer ${key}` }
15
+ }, (res) => {
16
+ if (res.statusCode === 200)
17
+ resolve(true);
18
+ else
19
+ resolve(false);
36
20
  });
21
+ req.on('error', () => resolve(false));
22
+ req.setTimeout(5000, () => req.destroy());
23
+ req.end();
37
24
  });
38
25
  }
26
+ async function checkKeyPermissions(key) {
27
+ // SEQUENTIAL CHECK (Avoid Rate Limits on Key Verification)
28
+ const endpoints = ['/account/profile', '/account/balance', '/account/usage'];
29
+ for (const ep of endpoints) {
30
+ const ok = await checkEndpoint(ep, key);
31
+ if (!ok)
32
+ return false; // Fail fast
33
+ }
34
+ return true;
35
+ }
39
36
  // === CONSTANTS & PRICING ===
40
37
  const TIER_LIMITS = {
41
38
  spore: { pollen: 1, emoji: '🦠' },
@@ -63,12 +63,11 @@ export async function getQuotaStatus(forceRefresh = false) {
63
63
  }
64
64
  try {
65
65
  logQuota("Fetching Quota Data...");
66
- // Fetch parallèle using HTTPS helper
67
- const [profileRes, balanceRes, usageRes] = await Promise.all([
68
- fetchAPI('/account/profile', config.apiKey),
69
- fetchAPI('/account/balance', config.apiKey),
70
- fetchAPI('/account/usage', config.apiKey)
71
- ]);
66
+ // SEQUENTIAL FETCH (Avoid Rate Limits)
67
+ // We fetch one by one. If one fails, we catch and return fallback.
68
+ const profileRes = await fetchAPI('/account/profile', config.apiKey);
69
+ const balanceRes = await fetchAPI('/account/balance', config.apiKey);
70
+ const usageRes = await fetchAPI('/account/usage', config.apiKey);
72
71
  logQuota(`Fetch Success. Tier: ${profileRes.tier}, Balance: ${balanceRes.balance}`);
73
72
  const profile = profileRes;
74
73
  const balance = balanceRes.balance;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opencode-pollinations-plugin",
3
3
  "displayName": "Pollinations AI (V5.1)",
4
- "version": "5.5.3",
4
+ "version": "5.5.4",
5
5
  "description": "Native Pollinations.ai Provider Plugin for OpenCode",
6
6
  "publisher": "pollinations",
7
7
  "repository": {