opencode-pollinations-plugin 5.5.4 → 5.5.5

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.
@@ -4,7 +4,6 @@ import { emitStatusToast } from './toast.js';
4
4
  import { getDetailedUsage } from './pollinations-api.js';
5
5
  import { generatePollinationsConfig } from './generate-config.js';
6
6
  import * as https from 'https';
7
- // --- HELPER: STRICT PERMISSION CHECK ---
8
7
  function checkEndpoint(ep, key) {
9
8
  return new Promise((resolve) => {
10
9
  const req = https.request({
@@ -14,12 +13,12 @@ function checkEndpoint(ep, key) {
14
13
  headers: { 'Authorization': `Bearer ${key}` }
15
14
  }, (res) => {
16
15
  if (res.statusCode === 200)
17
- resolve(true);
16
+ resolve({ ok: true });
18
17
  else
19
- resolve(false);
18
+ resolve({ ok: false, status: res.statusCode });
20
19
  });
21
- req.on('error', () => resolve(false));
22
- req.setTimeout(5000, () => req.destroy());
20
+ req.on('error', (e) => resolve({ ok: false, status: e.message || 'Error' }));
21
+ req.setTimeout(10000, () => req.destroy()); // 10s Timeout
23
22
  req.end();
24
23
  });
25
24
  }
@@ -27,11 +26,12 @@ async function checkKeyPermissions(key) {
27
26
  // SEQUENTIAL CHECK (Avoid Rate Limits on Key Verification)
28
27
  const endpoints = ['/account/profile', '/account/balance', '/account/usage'];
29
28
  for (const ep of endpoints) {
30
- const ok = await checkEndpoint(ep, key);
31
- if (!ok)
32
- return false; // Fail fast
29
+ const res = await checkEndpoint(ep, key);
30
+ if (!res.ok) {
31
+ return { ok: false, reason: `${ep} (${res.status})` };
32
+ }
33
33
  }
34
- return true;
34
+ return { ok: true };
35
35
  }
36
36
  // === CONSTANTS & PRICING ===
37
37
  const TIER_LIMITS = {
@@ -271,18 +271,23 @@ async function handleConnectCommand(args) {
271
271
  // CHECK RESTRICTIONS: Strict Check (Usage + Profile + Balance)
272
272
  let forcedModeMsg = "";
273
273
  let isLimited = false;
274
+ let limitReason = "";
274
275
  try {
275
276
  // Strict Probe: Must be able to read ALL accounting data
276
- const hasFullAccess = await checkKeyPermissions(key);
277
- isLimited = !hasFullAccess;
277
+ const check = await checkKeyPermissions(key);
278
+ if (!check.ok) {
279
+ isLimited = true;
280
+ limitReason = check.reason || "Unknown";
281
+ }
278
282
  }
279
283
  catch (e) {
280
284
  isLimited = true;
285
+ limitReason = e.message;
281
286
  }
282
287
  // If Limited -> FORCE MANUAL
283
288
  if (isLimited) {
284
289
  saveConfig({ apiKey: key, mode: 'manual', keyHasAccessToProfile: false });
285
- forcedModeMsg = "\n⚠️ **Clé Limitée** (Permissions insuffisantes) -> Mode **MANUAL** forcé.\n*Requis pour mode Auto: Profile, Balance & Usage.*";
290
+ forcedModeMsg = `\n⚠️ **Clé Limitée** (Echec: ${limitReason}) -> Mode **MANUAL** forcé.\n*Requis pour mode Auto: Profile, Balance & Usage.*`;
286
291
  }
287
292
  else {
288
293
  saveConfig({ apiKey: key, keyHasAccessToProfile: true }); // Let user keep current mode or default
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.4",
4
+ "version": "5.5.5",
5
5
  "description": "Native Pollinations.ai Provider Plugin for OpenCode",
6
6
  "publisher": "pollinations",
7
7
  "repository": {