opencode-pollinations-plugin 5.4.14 → 5.4.16

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.
@@ -226,7 +226,7 @@ async function handleConnectCommand(args) {
226
226
  const enterpriseModels = models.filter(m => m.id.startsWith('enter/'));
227
227
  if (enterpriseModels.length > 0) {
228
228
  // SUCCESS
229
- saveConfig({ apiKey: key, mode: 'pro' });
229
+ saveConfig({ apiKey: key }); // Don't force mode 'pro'. Let user decide.
230
230
  const masked = key.substring(0, 6) + '...';
231
231
  // Count Paid Only models found
232
232
  const diamondCount = enterpriseModels.filter(m => m.name.includes('💎')).length;
@@ -128,14 +128,16 @@ function readConfigFromDisk() {
128
128
  // 4. APPLY
129
129
  if (finalKey) {
130
130
  config.apiKey = finalKey;
131
- config.mode = 'pro';
132
- // logConfig(`Loaded Key from ${source}`); // Debug
131
+ // config.mode = 'pro'; // REMOVED: Mode is decoupled from Key presence.
133
132
  }
134
133
  else {
135
134
  // Ensure no phantom key remains
136
135
  delete config.apiKey;
137
- if (config.mode === 'pro')
138
- config.mode = 'manual';
136
+ // if (config.mode === 'pro') config.mode = 'manual'; // OPTIONAL: Downgrade if no key? User says "No link".
137
+ // Actually, if I am in PRO mode and lose my key, I am broken. Falling back to manual is safer?
138
+ // User said "Manual mode is like standard API".
139
+ // Let's REMOVE this auto-downgrade too to be strictly "Decoupled".
140
+ // If user is in PRO without key, they get "Missing Key" error, which is correct.
139
141
  }
140
142
  return { ...config, version: PKG_VERSION };
141
143
  }
@@ -260,7 +260,25 @@ export async function handleChatCompletion(req, res, bodyRaw) {
260
260
  // B. SAFETY NETS (The Core V5 Logic)
261
261
  if (config.mode === 'alwaysfree') {
262
262
  if (isEnterprise) {
263
- if (quota.tier === 'error') {
263
+ // NEW: Paid Only Check for Always Free
264
+ // If the user asks for a 💎 Paid Only model while in Always Free, we BLOCK it to save wallet
265
+ // and fallback to free specific message.
266
+ try {
267
+ const homedir = process.env.HOME || '/tmp';
268
+ const standardPaidPath = path.join(homedir, '.pollinations', 'pollinations-paid-models.json');
269
+ if (fs.existsSync(standardPaidPath)) {
270
+ const paidModels = JSON.parse(fs.readFileSync(standardPaidPath, 'utf-8'));
271
+ if (paidModels.includes(actualModel)) {
272
+ log(`[SafetyNet] alwaysfree Mode: Request for Paid Only Model (${actualModel}). FALLBACK.`);
273
+ actualModel = config.fallbacks.free.main.replace('free/', '');
274
+ isEnterprise = false;
275
+ isFallbackActive = true;
276
+ fallbackReason = "Mode AlwaysFree actif: Ce modèle payant consomme du wallet. Passez en mode PRO.";
277
+ }
278
+ }
279
+ }
280
+ catch (e) { }
281
+ if (!isFallbackActive && quota.tier === 'error') {
264
282
  log(`[SafetyNet] AlwaysFree Mode: Quota Check Failed. Switching to Free Fallback.`);
265
283
  actualModel = config.fallbacks.free.main.replace('free/', '');
266
284
  isEnterprise = false;
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.14",
4
+ "version": "5.4.16",
5
5
  "description": "Native Pollinations.ai Provider Plugin for OpenCode",
6
6
  "publisher": "pollinations",
7
7
  "repository": {