opencode-pollinations-plugin 5.1.21 → 5.1.22
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 } from './server/config.js';
|
|
5
|
+
import { loadConfig, updateCache } from './server/config.js';
|
|
6
6
|
import { handleChatCompletion } from './server/proxy.js';
|
|
7
7
|
import { createToastHooks, setGlobalClient } from './server/toast.js';
|
|
8
8
|
import { createStatusHooks } from './server/status.js';
|
|
@@ -100,7 +100,14 @@ export const PollinationsPlugin = async (ctx) => {
|
|
|
100
100
|
return {
|
|
101
101
|
async config(config) {
|
|
102
102
|
log("[Hook] config() called");
|
|
103
|
-
|
|
103
|
+
// Extract API Key from incoming config to ensure Hot Reload
|
|
104
|
+
const incomingKey = config.provider?.pollinations?.options?.apiKey ||
|
|
105
|
+
config.provider?.pollinations_enter?.options?.apiKey;
|
|
106
|
+
if (incomingKey) {
|
|
107
|
+
log(`[Hook] Detected API Key update.`);
|
|
108
|
+
updateCache({ apiKey: incomingKey, mode: 'pro' });
|
|
109
|
+
}
|
|
110
|
+
const modelsArray = await generatePollinationsConfig(incomingKey);
|
|
104
111
|
const modelsObj = {};
|
|
105
112
|
for (const m of modelsArray) {
|
|
106
113
|
// Ensure ID is relative for mapping ("free/gemini")
|
package/dist/server/config.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export interface PollinationsConfigV5 {
|
|
|
24
24
|
}
|
|
25
25
|
export declare function subscribeToConfigChange(callback: () => void): void;
|
|
26
26
|
export declare function loadConfig(): PollinationsConfigV5;
|
|
27
|
+
export declare function updateCache(newConfig: Partial<PollinationsConfigV5>): void;
|
|
27
28
|
export declare function saveConfig(updates: Partial<PollinationsConfigV5>): {
|
|
28
29
|
version: string;
|
|
29
30
|
mode: "manual" | "alwaysfree" | "pro";
|
package/dist/server/config.js
CHANGED
|
@@ -100,6 +100,11 @@ export function loadConfig() {
|
|
|
100
100
|
watchFileSafe(OPENCODE_CONFIG_FILE);
|
|
101
101
|
return cachedConfig;
|
|
102
102
|
}
|
|
103
|
+
export function updateCache(newConfig) {
|
|
104
|
+
const current = loadConfig();
|
|
105
|
+
cachedConfig = { ...current, ...newConfig };
|
|
106
|
+
logConfig(`Cache Force-Updated via Hook. Mode: ${cachedConfig.mode}`);
|
|
107
|
+
}
|
|
103
108
|
// INTERNAL READER (The old loadConfig logic)
|
|
104
109
|
function readConfigFromDisk() {
|
|
105
110
|
let config = { ...DEFAULT_CONFIG_V5 };
|
|
@@ -48,10 +48,13 @@ function formatName(id, censored = true) {
|
|
|
48
48
|
return clean;
|
|
49
49
|
}
|
|
50
50
|
// --- MAIN GENERATOR logic ---
|
|
51
|
-
|
|
51
|
+
// --- MAIN GENERATOR logic ---
|
|
52
|
+
export async function generatePollinationsConfig(forceApiKey) {
|
|
52
53
|
const config = loadConfig();
|
|
53
54
|
const modelsOutput = [];
|
|
54
|
-
log(`Starting Configuration (
|
|
55
|
+
log(`Starting Configuration (V5.1.22 Hot-Reload)...`);
|
|
56
|
+
// Use forced key (from Hook) or cached key
|
|
57
|
+
const effectiveKey = forceApiKey || config.apiKey;
|
|
55
58
|
// 1. FREE UNIVERSE
|
|
56
59
|
try {
|
|
57
60
|
// Switch to main models endpoint (User provided curl confirms it has 'description')
|
|
@@ -71,10 +74,10 @@ export async function generatePollinationsConfig() {
|
|
|
71
74
|
modelsOutput.push({ id: "free/gemini", name: "[Free] Gemini Flash (Fallback)", object: "model", variants: {} });
|
|
72
75
|
}
|
|
73
76
|
// 2. ENTERPRISE UNIVERSE
|
|
74
|
-
if (
|
|
77
|
+
if (effectiveKey && effectiveKey.length > 5 && effectiveKey !== 'dummy') {
|
|
75
78
|
try {
|
|
76
79
|
const enterListRaw = await fetchJson('https://gen.pollinations.ai/text/models', {
|
|
77
|
-
'Authorization': `Bearer ${
|
|
80
|
+
'Authorization': `Bearer ${effectiveKey}`
|
|
78
81
|
});
|
|
79
82
|
const enterList = Array.isArray(enterListRaw) ? enterListRaw : (enterListRaw.data || []);
|
|
80
83
|
enterList.forEach((m) => {
|
package/package.json
CHANGED