opencode-pollinations-plugin 6.1.0-beta.4 → 6.1.0-beta.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.
- package/dist/server/commands.js +18 -17
- package/dist/server/proxy.js +9 -0
- package/package.json +1 -1
package/dist/server/commands.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as https from 'https';
|
|
|
2
2
|
import { loadConfig, saveConfig } from './config.js';
|
|
3
3
|
import { getQuotaStatus } from './quota.js';
|
|
4
4
|
import { emitStatusToast } from './toast.js';
|
|
5
|
-
import { getDetailedUsage } from './pollinations-api.js';
|
|
5
|
+
import { getDetailedUsage, getAggregatedModels } from './pollinations-api.js';
|
|
6
6
|
import { generatePollinationsConfig } from './generate-config.js';
|
|
7
7
|
function checkEndpoint(ep, key) {
|
|
8
8
|
return new Promise((resolve) => {
|
|
@@ -145,7 +145,7 @@ export async function handleCommand(command) {
|
|
|
145
145
|
case 'connect':
|
|
146
146
|
return await handleConnectCommand(args);
|
|
147
147
|
case 'fallback':
|
|
148
|
-
return handleFallbackCommand(args);
|
|
148
|
+
return await handleFallbackCommand(args);
|
|
149
149
|
case 'config':
|
|
150
150
|
return handleConfigCommand(args);
|
|
151
151
|
case 'help':
|
|
@@ -265,7 +265,7 @@ async function handleUsageCommand(args) {
|
|
|
265
265
|
return { handled: true, error: `Erreur: ${e}` };
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
|
-
function handleFallbackCommand(args) {
|
|
268
|
+
async function handleFallbackCommand(args) {
|
|
269
269
|
let targetMode = args[0];
|
|
270
270
|
const targetModel = args[1];
|
|
271
271
|
if (!targetMode || !targetModel) {
|
|
@@ -280,20 +280,21 @@ function handleFallbackCommand(args) {
|
|
|
280
280
|
if (targetMode !== 'economy' && targetMode !== 'pro') {
|
|
281
281
|
return { handled: true, error: 'Target mode invalide (economy ou pro)' };
|
|
282
282
|
}
|
|
283
|
-
//
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
283
|
+
// DYNAMIC MODEL VALIDATION (BUG 2 FIX)
|
|
284
|
+
try {
|
|
285
|
+
const { data: models } = await getAggregatedModels();
|
|
286
|
+
const validIds = models.map(m => m.id.replace(/^pollinations\/(free|enter)\//, ''));
|
|
287
|
+
if (!validIds.includes(targetModel)) {
|
|
288
|
+
const suggestions = validIds.slice(0, 10).join(', ');
|
|
289
|
+
return {
|
|
290
|
+
handled: true,
|
|
291
|
+
error: `⚠️ Modèle inconnu: "${targetModel}".\nExemples valides: ${suggestions}...`
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
catch (e) {
|
|
296
|
+
// Fail-open si API down
|
|
297
|
+
console.warn('[Fallback] Model validation failed, allowing:', e);
|
|
297
298
|
}
|
|
298
299
|
const config = loadConfig();
|
|
299
300
|
const updates = { fallbacks: { ...config.fallbacks } };
|
package/dist/server/proxy.js
CHANGED
|
@@ -647,6 +647,15 @@ export async function handleChatCompletion(req, res, bodyRaw) {
|
|
|
647
647
|
log(`[SafetyNet] Adjusted max_tokens to 4000 for ${actualModel}`);
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
|
+
// BEDROCK COMPATIBILITY FIX (BUG 1)
|
|
651
|
+
const isBedrockModel = actualModel.includes('nova') ||
|
|
652
|
+
actualModel.includes('amazon') ||
|
|
653
|
+
actualModel.includes('chickytutor');
|
|
654
|
+
if (isBedrockModel && retryBody.tools) {
|
|
655
|
+
delete retryBody.tools;
|
|
656
|
+
log(`[SafetyNet] Tools removed for Bedrock model: ${actualModel}`);
|
|
657
|
+
emitStatusToast('warning', '⚠️ Tools désactivés (Bedrock incompatible)', 'Fallback');
|
|
658
|
+
}
|
|
650
659
|
// 4. Retry Fetch
|
|
651
660
|
const retryRes = await fetchWithRetry(targetUrl, {
|
|
652
661
|
method: 'POST',
|
package/package.json
CHANGED