opencode-pollinations-plugin 5.4.11 → 5.4.13
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
CHANGED
|
@@ -221,7 +221,7 @@ async function handleConnectCommand(args) {
|
|
|
221
221
|
// 1. Universal Validation (No Syntax Check) - Functional Check
|
|
222
222
|
emitStatusToast('info', 'Vérification de la clé...', 'Pollinations Config');
|
|
223
223
|
try {
|
|
224
|
-
const models = await generatePollinationsConfig(key);
|
|
224
|
+
const models = await generatePollinationsConfig(key, true);
|
|
225
225
|
// 2. Check if we got Enterprise models
|
|
226
226
|
const enterpriseModels = models.filter(m => m.id.startsWith('enter/'));
|
|
227
227
|
if (enterpriseModels.length > 0) {
|
package/dist/server/config.js
CHANGED
|
@@ -61,8 +61,15 @@ function readConfigFromDisk() {
|
|
|
61
61
|
catch (e) {
|
|
62
62
|
logConfig(`Error loading config: ${e}`);
|
|
63
63
|
}
|
|
64
|
-
// 2. Auth Store (
|
|
65
|
-
|
|
64
|
+
// 2. Auth Store (Fallback ONLY if config.json didn't exist or we are in a clear state)
|
|
65
|
+
// If config.json exists, it is the source of truth. We shouldn't resurrect old keys from auth.json
|
|
66
|
+
// UNLESS config.json is "empty" (just created default).
|
|
67
|
+
// But how to know?
|
|
68
|
+
// New logic: If Custom Config was loaded (fs.exists(CONFIG_FILE)), we trust it.
|
|
69
|
+
// We only check Auth Store if NO custom config exists OR if custom config is explicitly "manual" and we want to auto-discover?
|
|
70
|
+
// User complaint: "Old key comes back".
|
|
71
|
+
// Fix: If config.json exists, we DO NOT check auth.json.
|
|
72
|
+
if (!fs.existsSync(CONFIG_FILE) && !keyFound) {
|
|
66
73
|
try {
|
|
67
74
|
if (fs.existsSync(AUTH_FILE)) {
|
|
68
75
|
const raw = fs.readFileSync(AUTH_FILE, 'utf-8');
|
|
@@ -82,8 +89,8 @@ function readConfigFromDisk() {
|
|
|
82
89
|
logConfig(`Error reading auth.json: ${e}`);
|
|
83
90
|
}
|
|
84
91
|
}
|
|
85
|
-
// 3. OpenCode Config (Fallback)
|
|
86
|
-
if (!keyFound) {
|
|
92
|
+
// 3. OpenCode Config (Fallback ONLY if config.json does NOT exist)
|
|
93
|
+
if (!fs.existsSync(CONFIG_FILE) && !keyFound) {
|
|
87
94
|
try {
|
|
88
95
|
if (fs.existsSync(OPENCODE_CONFIG_FILE)) {
|
|
89
96
|
const raw = fs.readFileSync(OPENCODE_CONFIG_FILE, 'utf-8');
|
|
@@ -9,5 +9,5 @@ interface OpenCodeModel {
|
|
|
9
9
|
output?: number;
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
export declare function generatePollinationsConfig(forceApiKey?: string): Promise<OpenCodeModel[]>;
|
|
12
|
+
export declare function generatePollinationsConfig(forceApiKey?: string, forceStrict?: boolean): Promise<OpenCodeModel[]>;
|
|
13
13
|
export {};
|
|
@@ -54,7 +54,7 @@ function formatName(id, censored = true) {
|
|
|
54
54
|
}
|
|
55
55
|
// --- MAIN GENERATOR logic ---
|
|
56
56
|
// --- MAIN GENERATOR logic ---
|
|
57
|
-
export async function generatePollinationsConfig(forceApiKey) {
|
|
57
|
+
export async function generatePollinationsConfig(forceApiKey, forceStrict = false) {
|
|
58
58
|
const config = loadConfig();
|
|
59
59
|
const modelsOutput = [];
|
|
60
60
|
log(`Starting Configuration (V5.1.22 Hot-Reload)...`);
|
|
@@ -93,7 +93,7 @@ export async function generatePollinationsConfig(forceApiKey) {
|
|
|
93
93
|
// 2. ENTERPRISE UNIVERSE
|
|
94
94
|
if (effectiveKey && effectiveKey.length > 5 && effectiveKey !== 'dummy') {
|
|
95
95
|
try {
|
|
96
|
-
const enterListRaw = await fetchJson('https://gen.pollinations.ai/
|
|
96
|
+
const enterListRaw = await fetchJson('https://gen.pollinations.ai/models', {
|
|
97
97
|
'Authorization': `Bearer ${effectiveKey}`
|
|
98
98
|
});
|
|
99
99
|
const enterList = Array.isArray(enterListRaw) ? enterListRaw : (enterListRaw.data || []);
|
|
@@ -122,6 +122,9 @@ export async function generatePollinationsConfig(forceApiKey) {
|
|
|
122
122
|
}
|
|
123
123
|
catch (e) {
|
|
124
124
|
log(`Error fetching Enterprise models: ${e}`);
|
|
125
|
+
// STRICT MODE (Validation): Do not return fake fallback models.
|
|
126
|
+
if (forceStrict)
|
|
127
|
+
throw e;
|
|
125
128
|
// Fallback Robust for Enterprise (User has Key but discovery failed)
|
|
126
129
|
modelsOutput.push({ id: "enter/gpt-4o", name: "[Enter] GPT-4o (Fallback)", object: "model", variants: {} });
|
|
127
130
|
// ...
|
package/package.json
CHANGED