opencode-pollinations-plugin 5.2.2 → 5.2.3

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.
@@ -446,14 +446,21 @@ export async function handleChatCompletion(req, res, bodyRaw) {
446
446
  });
447
447
  if (!fetchRes.ok) {
448
448
  log(`Upstream Error: ${fetchRes.status} ${fetchRes.statusText}`);
449
- // TRANSPARENT FALLBACK ON 402 (Payment) or 429 (Rate Limit) IF Enterprise
450
- if ((fetchRes.status === 402 || fetchRes.status === 429) && isEnterprise) {
449
+ // TRANSPARENT FALLBACK ON 4xx Errors (Payment, Rate Limit, Auth) IF Enterprise
450
+ if ((fetchRes.status === 402 || fetchRes.status === 429 || fetchRes.status === 401 || fetchRes.status === 403) && isEnterprise) {
451
451
  log(`[SafetyNet] Upstream Rejection (${fetchRes.status}). Triggering Transparent Fallback.`);
452
452
  // 1. Switch Config
453
453
  actualModel = config.fallbacks.free.main.replace('free/', '');
454
454
  isEnterprise = false;
455
455
  isFallbackActive = true;
456
- fallbackReason = fetchRes.status === 402 ? "Insufficient Funds (Upstream 402)" : "Rate Limit (Upstream 429)";
456
+ if (fetchRes.status === 402)
457
+ fallbackReason = "Insufficient Funds (Upstream 402)";
458
+ else if (fetchRes.status === 429)
459
+ fallbackReason = "Rate Limit (Upstream 429)";
460
+ else if (fetchRes.status === 401)
461
+ fallbackReason = "Invalid API Key (Upstream 401)";
462
+ else
463
+ fallbackReason = `Access Denied (${fetchRes.status})`;
457
464
  // 2. Notify
458
465
  emitStatusToast('warning', `⚠️ Safety Net: ${actualModel} (${fallbackReason})`, 'Pollinations Safety');
459
466
  emitLogToast('warning', `Recovering from ${fetchRes.status} -> Switching to ${actualModel}`, 'Safety Net');
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.2.2",
4
+ "version": "5.2.3",
5
5
  "description": "Native Pollinations.ai Provider Plugin for OpenCode",
6
6
  "publisher": "pollinations",
7
7
  "repository": {