opencode-pollinations-plugin 5.1.17 → 5.1.18
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/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as http from 'http';
|
|
|
2
2
|
import * as fs from 'fs';
|
|
3
3
|
import { execSync } from 'child_process';
|
|
4
4
|
import { generatePollinationsConfig } from './server/generate-config.js';
|
|
5
|
-
import { loadConfig
|
|
5
|
+
import { loadConfig } from './server/config.js';
|
|
6
6
|
import { handleChatCompletion } from './server/proxy.js';
|
|
7
7
|
import { createToastHooks, setGlobalClient, emitStatusToast } from './server/toast.js';
|
|
8
8
|
import { createStatusHooks } from './server/status.js';
|
|
@@ -34,11 +34,7 @@ catch (e) {
|
|
|
34
34
|
}
|
|
35
35
|
// === GESTION DU CYCLE DE VIE PROXY ===
|
|
36
36
|
// CONFIG WATCHER (Hot Reload)
|
|
37
|
-
|
|
38
|
-
const config = loadConfig();
|
|
39
|
-
log(`[HotReload] Config changed. Mode: ${config.mode}`);
|
|
40
|
-
emitStatusToast('info', `Config Reloaded: ${config.mode}`, 'Pollinations');
|
|
41
|
-
});
|
|
37
|
+
// CONFIG WATCHER REMOVED (Legacy)
|
|
42
38
|
const startProxy = () => {
|
|
43
39
|
return new Promise((resolve) => {
|
|
44
40
|
const server = http.createServer(async (req, res) => {
|
|
@@ -132,7 +128,12 @@ export const PollinationsPlugin = async (ctx) => {
|
|
|
132
128
|
return {
|
|
133
129
|
async config(config) {
|
|
134
130
|
log("[Hook] config() called");
|
|
135
|
-
|
|
131
|
+
// Extract API Key from incoming config to ensure Hot Reload
|
|
132
|
+
const incomingKey = config.provider?.pollinations?.options?.apiKey ||
|
|
133
|
+
config.provider?.pollinations_enter?.options?.apiKey;
|
|
134
|
+
if (incomingKey)
|
|
135
|
+
log(`[Hook] Detected API Key update.`);
|
|
136
|
+
const modelsArray = await generatePollinationsConfig(incomingKey);
|
|
136
137
|
const modelsObj = {};
|
|
137
138
|
for (const m of modelsArray) {
|
|
138
139
|
// Ensure ID is relative for mapping ("free/gemini")
|
|
@@ -48,10 +48,12 @@ function formatName(id, censored = true) {
|
|
|
48
48
|
return clean;
|
|
49
49
|
}
|
|
50
50
|
// --- MAIN GENERATOR logic ---
|
|
51
|
-
export async function generatePollinationsConfig() {
|
|
51
|
+
export async function generatePollinationsConfig(forceApiKey) {
|
|
52
52
|
const config = loadConfig();
|
|
53
53
|
const modelsOutput = [];
|
|
54
|
-
|
|
54
|
+
// Use forced key (from Hook) or cached key
|
|
55
|
+
const effectiveKey = forceApiKey || config.apiKey;
|
|
56
|
+
log(`Starting Configuration (V5.1.18 Hot-Reload)...`);
|
|
55
57
|
// 1. FREE UNIVERSE
|
|
56
58
|
try {
|
|
57
59
|
// Switch to main models endpoint (User provided curl confirms it has 'description')
|
|
@@ -71,10 +73,10 @@ export async function generatePollinationsConfig() {
|
|
|
71
73
|
modelsOutput.push({ id: "free/gemini", name: "[Free] Gemini Flash (Fallback)", object: "model", variants: {} });
|
|
72
74
|
}
|
|
73
75
|
// 2. ENTERPRISE UNIVERSE
|
|
74
|
-
if (
|
|
76
|
+
if (effectiveKey && effectiveKey.length > 5 && effectiveKey !== 'dummy') {
|
|
75
77
|
try {
|
|
76
78
|
const enterListRaw = await fetchJson('https://gen.pollinations.ai/text/models', {
|
|
77
|
-
'Authorization': `Bearer ${
|
|
79
|
+
'Authorization': `Bearer ${effectiveKey}`
|
|
78
80
|
});
|
|
79
81
|
const enterList = Array.isArray(enterListRaw) ? enterListRaw : (enterListRaw.data || []);
|
|
80
82
|
enterList.forEach((m) => {
|
package/package.json
CHANGED