opencode-pollinations-plugin 5.4.1 → 5.4.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.
@@ -73,6 +73,13 @@ export async function generatePollinationsConfig(forceApiKey) {
73
73
  modelsOutput.push({ id: "free/openai", name: "[Free] OpenAI (Fallback)", object: "model", variants: {} });
74
74
  modelsOutput.push({ id: "free/gemini", name: "[Free] Gemini Flash (Fallback)", object: "model", variants: {} });
75
75
  }
76
+ // 1.5 FORCE ENSURE CRITICAL MODELS
77
+ // Sometimes the API list changes or is cached weirdly. We force vital models.
78
+ const hasGemini = modelsOutput.find(m => m.id === 'free/gemini');
79
+ if (!hasGemini) {
80
+ log(`[ConfigGen] Force-injecting free/gemini.`);
81
+ modelsOutput.push({ id: "free/gemini", name: "[Free] Gemini Flash (Force)", object: "model", variants: {} });
82
+ }
76
83
  // 2. ENTERPRISE UNIVERSE
77
84
  if (effectiveKey && effectiveKey.length > 5 && effectiveKey !== 'dummy') {
78
85
  try {
@@ -126,7 +126,9 @@ async function fetchWithRetry(url, options, retries = MAX_RETRIES) {
126
126
  // Don't retry client errors (except rate limit)
127
127
  return response;
128
128
  }
129
- if (retries > 0 && (response.status === 429 || response.status >= 500)) {
129
+ if (retries > 0 && (response.status === 429 || response.status >= 500 || response.status === 520)) {
130
+ // Check for specific "Queue" message in 520/429 body if possible (async read?)
131
+ // For now, just retry blindly on 520/5xx
130
132
  log(`[Retry] Upstream Error ${response.status}. Retrying in ${RETRY_DELAY_MS}ms... (${retries} left)`);
131
133
  await sleep(RETRY_DELAY_MS);
132
134
  return fetchWithRetry(url, options, retries - 1);
@@ -365,22 +367,22 @@ export async function handleChatCompletion(req, res, bodyRaw) {
365
367
  const name = t.function?.name || t.name;
366
368
  return isFunc && name !== 'google_search';
367
369
  });
368
- // 2. Sanitize (Tools Config Removed for Safety)
370
+ // 2. Sanitize & RESTORE GROUNDING CONFIG (Essential for Vertex Auth)
369
371
  if (proxyBody.tools.length > 0) {
370
- // proxyBody.tools_config = { google_search_retrieval: { disable: true } };
372
+ // v5.4.1: MUST send tools_config to avoid 401 Unauthorized on Vertex
373
+ proxyBody.tools_config = { google_search_retrieval: { disable: true } };
371
374
  proxyBody.tools = sanitizeToolsForVertex(proxyBody.tools);
372
375
  }
373
376
  else {
374
377
  // 3. If no tools left (or only search was present), DELETE 'tools' entirely
375
- // Sending tools: [] or tools_config without tools causes 400 Bad Request
376
378
  delete proxyBody.tools;
377
379
  if (proxyBody.tools_config)
378
380
  delete proxyBody.tools_config;
379
381
  }
380
382
  }
381
- // 4. STOP SEQUENCES REMOVED (Validation Fix v5.4.0)
382
- // if (!proxyBody.stop) { ... }
383
- log(`[Proxy] Gemini Logic: Tools=${proxyBody.tools ? proxyBody.tools.length : 'REMOVED'}, Stops Injected.`);
383
+ // 4. STOP SEQUENCES REMOVED (Validation Fix v5.4.0/1)
384
+ // Do NOT inject stop sequences (User:/Model:) as they cause "JSON body validation failed".
385
+ log(`[Proxy] Gemini Logic: Tools=${proxyBody.tools ? proxyBody.tools.length : 'REMOVED'}, Stops NOT Injected.`);
384
386
  }
385
387
  }
386
388
  // C. GEMINI ID BACKTRACKING & SIGNATURE
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.4.1",
4
+ "version": "5.4.3",
5
5
  "description": "Native Pollinations.ai Provider Plugin for OpenCode",
6
6
  "publisher": "pollinations",
7
7
  "repository": {