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, subscribeToConfigChange } from './server/config.js';
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
- subscribeToConfigChange(() => {
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
- const modelsArray = await generatePollinationsConfig();
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")
@@ -9,5 +9,5 @@ interface OpenCodeModel {
9
9
  output?: number;
10
10
  };
11
11
  }
12
- export declare function generatePollinationsConfig(): Promise<OpenCodeModel[]>;
12
+ export declare function generatePollinationsConfig(forceApiKey?: string): Promise<OpenCodeModel[]>;
13
13
  export {};
@@ -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
- log(`Starting Configuration (V4.5 Clean Dynamic)...`);
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 (config.apiKey && config.apiKey.length > 5 && config.apiKey !== 'dummy') {
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 ${config.apiKey}`
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opencode-pollinations-plugin",
3
3
  "displayName": "Pollinations AI (V5.1)",
4
- "version": "5.1.17",
4
+ "version": "5.1.18",
5
5
  "description": "Native Pollinations.ai Provider Plugin for OpenCode",
6
6
  "publisher": "pollinations",
7
7
  "repository": {