opencode-pollinations-plugin 5.6.0-beta.3 → 5.6.0-beta.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.
@@ -1,8 +1,38 @@
1
+ import * as https from 'https';
1
2
  import { loadConfig, saveConfig } from './config.js';
2
3
  import { getQuotaStatus } from './quota.js';
3
4
  import { emitStatusToast } from './toast.js';
4
5
  import { getDetailedUsage } from './pollinations-api.js';
5
6
  import { generatePollinationsConfig } from './generate-config.js';
7
+ function checkEndpoint(ep, key) {
8
+ return new Promise((resolve) => {
9
+ const req = https.request({
10
+ hostname: 'gen.pollinations.ai',
11
+ path: ep,
12
+ method: 'GET',
13
+ headers: { 'Authorization': `Bearer ${key}` }
14
+ }, (res) => {
15
+ if (res.statusCode === 200)
16
+ resolve({ ok: true });
17
+ else
18
+ resolve({ ok: false, status: res.statusCode });
19
+ });
20
+ req.on('error', (e) => resolve({ ok: false, status: e.message || 'Error' }));
21
+ req.setTimeout(10000, () => req.destroy()); // 10s Timeout
22
+ req.end();
23
+ });
24
+ }
25
+ async function checkKeyPermissions(key) {
26
+ // SEQUENTIAL CHECK (Avoid Rate Limits on Key Verification)
27
+ const endpoints = ['/account/profile', '/account/balance', '/account/usage'];
28
+ for (const ep of endpoints) {
29
+ const res = await checkEndpoint(ep, key);
30
+ if (!res.ok) {
31
+ return { ok: false, reason: `${ep} (${res.status})` };
32
+ }
33
+ }
34
+ return { ok: true };
35
+ }
6
36
  // === CONSTANTS & PRICING ===
7
37
  const TIER_LIMITS = {
8
38
  spore: { pollen: 1, emoji: '🦠' },
@@ -44,12 +44,11 @@ export async function getQuotaStatus(forceRefresh = false) {
44
44
  }
45
45
  try {
46
46
  logQuota("Fetching Quota Data...");
47
- // Fetch parallèle using HTTPS helper
48
- const [profileRes, balanceRes, usageRes] = await Promise.all([
49
- fetchAPI('/account/profile', config.apiKey),
50
- fetchAPI('/account/balance', config.apiKey),
51
- fetchAPI('/account/usage', config.apiKey)
52
- ]);
47
+ // SEQUENTIAL FETCH (Avoid Rate Limits)
48
+ // We fetch one by one. If one fails, we catch and return fallback.
49
+ const profileRes = await fetchAPI('/account/profile', config.apiKey);
50
+ const balanceRes = await fetchAPI('/account/balance', config.apiKey);
51
+ const usageRes = await fetchAPI('/account/usage', config.apiKey);
53
52
  logQuota(`Fetch Success. Tier: ${profileRes.tier}, Balance: ${balanceRes.balance}`);
54
53
  const profile = profileRes;
55
54
  const balance = balanceRes.balance;
@@ -0,0 +1,9 @@
1
+ import { createRequire } from 'module';
2
+ const require = createRequire(import.meta.url);
3
+ try {
4
+ const pkg = require('../package.json');
5
+ console.log("SUCCESS: Loaded version " + pkg.version);
6
+ } catch (e) {
7
+ console.error("FAILURE:", e.message);
8
+ process.exit(1);
9
+ }
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.6.0-beta.3",
4
+ "version": "5.6.0-beta.4",
5
5
  "description": "Native Pollinations.ai Provider Plugin for OpenCode",
6
6
  "publisher": "pollinations",
7
7
  "repository": {