opencode-pollinations-plugin 6.1.0-beta.2 → 6.1.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.
- package/dist/server/commands.js +32 -24
- package/dist/server/config.js +5 -0
- package/dist/server/proxy.js +8 -0
- package/package.json +1 -1
package/dist/server/commands.js
CHANGED
|
@@ -159,7 +159,7 @@ export async function handleCommand(command) {
|
|
|
159
159
|
}
|
|
160
160
|
// === SUB-COMMANDS ===
|
|
161
161
|
async function handleModeCommand(args) {
|
|
162
|
-
|
|
162
|
+
let mode = args[0];
|
|
163
163
|
if (!mode) {
|
|
164
164
|
const config = loadConfig();
|
|
165
165
|
return {
|
|
@@ -167,15 +167,17 @@ async function handleModeCommand(args) {
|
|
|
167
167
|
response: `Mode actuel: ${config.mode}`
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
|
-
if (
|
|
170
|
+
if (mode === 'alwaysfree')
|
|
171
|
+
mode = 'economy'; // Alias support
|
|
172
|
+
if (!['manual', 'economy', 'pro'].includes(mode)) {
|
|
171
173
|
return {
|
|
172
174
|
handled: true,
|
|
173
|
-
error:
|
|
175
|
+
error: `❌ Mode invalide: ${mode}. Valeurs: manual, economy, pro`
|
|
174
176
|
};
|
|
175
177
|
}
|
|
176
178
|
const checkConfig = loadConfig();
|
|
177
|
-
// JIT VERIFICATION for PRO and
|
|
178
|
-
if (mode === 'pro' || mode === '
|
|
179
|
+
// JIT VERIFICATION for PRO and ECONOMY Mode
|
|
180
|
+
if (mode === 'pro' || mode === 'economy') {
|
|
179
181
|
const checkConfig = loadConfig(); // Reload to be sure
|
|
180
182
|
const key = checkConfig.apiKey;
|
|
181
183
|
if (!key) {
|
|
@@ -264,36 +266,42 @@ async function handleUsageCommand(args) {
|
|
|
264
266
|
}
|
|
265
267
|
}
|
|
266
268
|
function handleFallbackCommand(args) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
269
|
+
let targetMode = args[0];
|
|
270
|
+
const targetModel = args[1];
|
|
271
|
+
if (!targetMode || !targetModel) {
|
|
270
272
|
return {
|
|
271
273
|
handled: true,
|
|
272
|
-
|
|
274
|
+
error: `Usage: /pollinations fallback [economy|pro] <modèle>`
|
|
273
275
|
};
|
|
274
276
|
}
|
|
275
|
-
|
|
276
|
-
if (
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
return {
|
|
281
|
-
handled: true,
|
|
282
|
-
response: `✅ Fallback Economy configuré: ${model}`
|
|
283
|
-
};
|
|
277
|
+
// Alias support
|
|
278
|
+
if (targetMode === 'alwaysfree')
|
|
279
|
+
targetMode = 'economy';
|
|
280
|
+
if (targetMode !== 'economy' && targetMode !== 'pro') {
|
|
281
|
+
return { handled: true, error: 'Target mode invalide (economy ou pro)' };
|
|
284
282
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
283
|
+
// Validate Model
|
|
284
|
+
const KNOWN_MODELS = [
|
|
285
|
+
"openai", "openai-fast", "openai-large", "qwen-coder", "mistral", "openai-audio", "gemini", "gemini-fast",
|
|
286
|
+
"deepseek", "grok", "gemini-search", "chickytutor", "midijourney", "claude-fast", "claude", "claude-large",
|
|
287
|
+
"perplexity-fast", "perplexity-reasoning", "kimi", "gemini-large", "gemini-legacy", "nova-fast", "glm", "minimax",
|
|
288
|
+
"nomnom", "gpt-5-nano", "gpt-5.2", "openai-reasoning", "qwen3-coder", "deepseek-v3", "deepseek-reasoning",
|
|
289
|
+
"gemini-2.5-flash-lite", "claude-sonnet-4.5", "claude-sonnet", "amazon-nova-micro", "nova", "nova-micro"
|
|
290
|
+
];
|
|
291
|
+
// Tolerant check (if missing from known list, warn but allow if looks valid pattern? No, strict warn is better as requested)
|
|
292
|
+
if (!KNOWN_MODELS.includes(targetModel)) {
|
|
289
293
|
return {
|
|
290
294
|
handled: true,
|
|
291
|
-
|
|
295
|
+
error: `⚠️ Modèle inconnu: "${targetModel}".\nModèles valides: ${KNOWN_MODELS.slice(0, 5).join(', ')}... (voir doc)`
|
|
292
296
|
};
|
|
293
297
|
}
|
|
298
|
+
const config = loadConfig();
|
|
299
|
+
const updates = { fallbacks: { ...config.fallbacks } };
|
|
300
|
+
updates.fallbacks[targetMode] = targetModel;
|
|
301
|
+
saveConfig(updates);
|
|
294
302
|
return {
|
|
295
303
|
handled: true,
|
|
296
|
-
|
|
304
|
+
response: `✅ Fallback ${targetMode.charAt(0).toUpperCase() + targetMode.slice(1)} configuré: ${targetModel}`
|
|
297
305
|
};
|
|
298
306
|
}
|
|
299
307
|
async function handleConnectCommand(args) {
|
package/dist/server/config.js
CHANGED
|
@@ -59,6 +59,11 @@ function migrateConfig(config) {
|
|
|
59
59
|
delete config.fallbacks.free;
|
|
60
60
|
logConfig('[Migration] fallbacks.free → fallbacks.economy');
|
|
61
61
|
}
|
|
62
|
+
// Remove obsolete 'enter' fallback
|
|
63
|
+
if (config.fallbacks?.enter) {
|
|
64
|
+
delete config.fallbacks.enter;
|
|
65
|
+
logConfig('[Migration] Removed obsolete fallbacks.enter');
|
|
66
|
+
}
|
|
62
67
|
// Migrate old wallet threshold
|
|
63
68
|
if (config.thresholds?.wallet) {
|
|
64
69
|
if (!config.thresholds.wallet_warn) {
|
package/dist/server/proxy.js
CHANGED
|
@@ -639,6 +639,14 @@ export async function handleChatCompletion(req, res, bodyRaw) {
|
|
|
639
639
|
const retryHeaders = { ...headers };
|
|
640
640
|
// Keep Authorization for gen.pollinations.ai
|
|
641
641
|
const retryBody = { ...proxyBody, model: actualModel };
|
|
642
|
+
// LIMIT MAX_TOKENS for lightweight fallback models (e.g. nova-fast limits)
|
|
643
|
+
if (actualModel.includes('nova') || actualModel.includes('fast')) {
|
|
644
|
+
// Force max_tokens down if missing or too high
|
|
645
|
+
if (!retryBody.max_tokens || retryBody.max_tokens > 4000) {
|
|
646
|
+
retryBody.max_tokens = 4000;
|
|
647
|
+
log(`[SafetyNet] Adjusted max_tokens to 4000 for ${actualModel}`);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
642
650
|
// 4. Retry Fetch
|
|
643
651
|
const retryRes = await fetchWithRetry(targetUrl, {
|
|
644
652
|
method: 'POST',
|
package/package.json
CHANGED