opencode-pollinations-plugin 5.1.16 → 5.1.17

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.
Files changed (2) hide show
  1. package/dist/index.js +33 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2,9 +2,9 @@ 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, subscribeToConfigChange } from './server/config.js';
6
6
  import { handleChatCompletion } from './server/proxy.js';
7
- import { createToastHooks, setGlobalClient } from './server/toast.js';
7
+ import { createToastHooks, setGlobalClient, emitStatusToast } from './server/toast.js';
8
8
  import { createStatusHooks } from './server/status.js';
9
9
  import { createCommandHooks } from './server/commands.js';
10
10
  const LIFE_LOG = '/tmp/POLLI_LIFECYCLE.log';
@@ -27,11 +27,18 @@ try {
27
27
  log(`[Init] Checking port ${TRACKING_PORT} for zombies...`);
28
28
  execSync(`fuser -k ${TRACKING_PORT}/tcp || true`);
29
29
  log(`[Init] Port ${TRACKING_PORT} cleaned.`);
30
+ execSync('sleep 1');
30
31
  }
31
32
  catch (e) {
32
33
  log(`[Init] Zombie cleanup warning: ${e}`);
33
34
  }
34
35
  // === GESTION DU CYCLE DE VIE PROXY ===
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
+ });
35
42
  const startProxy = () => {
36
43
  return new Promise((resolve) => {
37
44
  const server = http.createServer(async (req, res) => {
@@ -49,13 +56,29 @@ const startProxy = () => {
49
56
  res.writeHead(200, { 'Content-Type': 'application/json' });
50
57
  res.end(JSON.stringify({
51
58
  status: "ok",
52
- version: "v4.0.5",
53
- mode: config.mode
59
+ version: "v5.1.17",
60
+ mode: config.mode,
61
+ pid: process.pid
54
62
  }));
55
63
  return;
56
64
  }
65
+ // RESTORED: Models Endpoint
66
+ if (req.method === 'GET' && req.url === '/v1/models') {
67
+ try {
68
+ const { getAggregatedModels } = await import('./server/pollinations-api.js');
69
+ const models = await getAggregatedModels();
70
+ res.writeHead(200, { 'Content-Type': 'application/json' });
71
+ res.end(JSON.stringify(models));
72
+ log(`[Proxy] Served ${models.data?.length || 0} models`);
73
+ }
74
+ catch (e) {
75
+ log(`[Proxy] Error fetching models: ${e}`);
76
+ res.writeHead(500);
77
+ res.end(JSON.stringify({ error: String(e) }));
78
+ }
79
+ return;
80
+ }
57
81
  // SUPPORT FLEXIBLE DES PATHS
58
- // Le SDK peut envoyer /v1/chat/completions ou juste /chat/completions
59
82
  if (req.method === 'POST' && (req.url === '/v1/chat/completions' || req.url === '/chat/completions')) {
60
83
  const chunks = [];
61
84
  req.on('data', chunk => chunks.push(chunk));
@@ -63,9 +86,10 @@ const startProxy = () => {
63
86
  try {
64
87
  const bodyRaw = Buffer.concat(chunks).toString();
65
88
  await handleChatCompletion(req, res, bodyRaw);
89
+ log(`[Proxy] Chat Completion Success`);
66
90
  }
67
91
  catch (e) {
68
- log(`Error: ${e}`);
92
+ log(`[Proxy] Chat Error: ${e}`);
69
93
  if (!res.headersSent) {
70
94
  res.writeHead(500);
71
95
  res.end(JSON.stringify({ error: String(e) }));
@@ -79,11 +103,12 @@ const startProxy = () => {
79
103
  res.end("Not Found");
80
104
  });
81
105
  server.listen(TRACKING_PORT, '127.0.0.1', () => {
82
- log(`[Proxy] Started V4 on port ${TRACKING_PORT}`);
106
+ log(`[Proxy] Started V5.1.17 on port ${TRACKING_PORT}`);
83
107
  resolve(TRACKING_PORT);
84
108
  });
85
109
  server.on('error', (e) => {
86
110
  log(`[Proxy] Fatal Error: ${e}`);
111
+ // Retry logic could go here, but for now log is key
87
112
  resolve(0);
88
113
  });
89
114
  });
@@ -126,6 +151,7 @@ export const PollinationsPlugin = async (ctx) => {
126
151
  models: modelsObj
127
152
  };
128
153
  log(`[Hook] Registered ${Object.keys(modelsObj).length} models.`);
154
+ emitStatusToast('info', `${Object.keys(modelsObj).length} Models Loaded`, 'Pollinations');
129
155
  },
130
156
  ...toastHooks,
131
157
  ...createStatusHooks(ctx.client), // New Status Bar Logic
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.16",
4
+ "version": "5.1.17",
5
5
  "description": "Native Pollinations.ai Provider Plugin for OpenCode",
6
6
  "publisher": "pollinations",
7
7
  "repository": {