opencode-pollinations-plugin 5.3.0 → 5.3.2

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/bin/setup.js CHANGED
File without changes
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as http from 'http';
2
2
  import * as fs from 'fs';
3
+ import { execSync } from 'child_process';
3
4
  import { generatePollinationsConfig } from './server/generate-config.js';
4
5
  import { loadConfig } from './server/config.js';
5
6
  import { handleChatCompletion } from './server/proxy.js';
@@ -14,43 +15,19 @@ function log(msg) {
14
15
  catch (e) { }
15
16
  }
16
17
  const TRACKING_PORT = 10001;
17
- // === ANTI-ZOMBIE / PORT MANAGMENT (CROSS-PLATFORM) ===
18
- // Instead of killing specific PIDs (which requires OS-specific commands like fuser/taskkill),
19
- // we use a "Try to Listen" approach. If the port is busy, we assume it's a previous instance
20
- // of ourselves (or another plugin instance) and we try to reuse it or fail gracefully.
21
- // This works on Windows, Linux, and macOS without external dependencies.
22
- const tryListen = (server, port, retries = 3) => {
23
- return new Promise((resolve, reject) => {
24
- server.once('error', (err) => {
25
- if (err.code === 'EADDRINUSE') {
26
- if (retries > 0) {
27
- log(`[Init] Port ${port} busy. Retrying in 500ms... (${retries} left)`);
28
- setTimeout(() => {
29
- server.close();
30
- server.listen(port, '127.0.0.1'); // Retry listen
31
- }, 500);
32
- }
33
- else {
34
- log(`[Init] Port ${port} still busy. Assuming persistent instance.`);
35
- resolve(); // Resolve anyway, assuming existing instance will handle requests
36
- }
37
- }
38
- else {
39
- reject(err);
40
- }
41
- });
42
- server.once('listening', () => {
43
- log(`[Init] Proxy successfully bound to port ${port}`);
44
- resolve();
45
- });
46
- server.listen(port, '127.0.0.1');
47
- });
48
- };
49
- // === GESTION DU CYCLE DE VIE PROXY ===
18
+ // === ANTI-ZOMBIE (LINUX/MAC LEGACY STABLE) ===
19
+ try {
20
+ log(`[Init] Cleaning port ${TRACKING_PORT}...`);
21
+ execSync(`fuser -k ${TRACKING_PORT}/tcp || true`);
22
+ }
23
+ catch (e) {
24
+ // Ignore on non-Linux or if no process found
25
+ }
50
26
  const startProxy = () => {
51
- return new Promise(async (resolve) => {
27
+ return new Promise((resolve) => {
52
28
  const server = http.createServer(async (req, res) => {
53
- // ... (Request Handling - Unchanged) ...
29
+ // ... (Request Handling) ...
30
+ // We reuse the existing logic structure but simplified startup
54
31
  log(`[Proxy] Request: ${req.method} ${req.url}`);
55
32
  res.setHeader('Access-Control-Allow-Origin', '*');
56
33
  res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
@@ -65,7 +42,7 @@ const startProxy = () => {
65
42
  res.writeHead(200, { 'Content-Type': 'application/json' });
66
43
  res.end(JSON.stringify({
67
44
  status: "ok",
68
- version: "v5.3.0",
45
+ version: "v5.3.2",
69
46
  mode: config.mode
70
47
  }));
71
48
  return;
@@ -92,20 +69,19 @@ const startProxy = () => {
92
69
  res.writeHead(404);
93
70
  res.end("Not Found");
94
71
  });
95
- // Robust Startup Logic
96
- try {
97
- await tryListen(server, TRACKING_PORT, 3);
72
+ server.listen(TRACKING_PORT, '127.0.0.1', () => {
73
+ log(`[Proxy] Started V5.3.2 (Legacy Port Logic) on port ${TRACKING_PORT}`);
98
74
  resolve(TRACKING_PORT);
99
- }
100
- catch (e) {
101
- log(`[Proxy] Fatal Bind Error: ${e}`);
102
- resolve(0); // Should handle gracefully upper in stack
103
- }
75
+ });
76
+ server.on('error', (e) => {
77
+ log(`[Proxy] Fatal Error: ${e}`);
78
+ resolve(0);
79
+ });
104
80
  });
105
81
  };
106
82
  // === PLUGIN EXPORT ===
107
83
  export const PollinationsPlugin = async (ctx) => {
108
- log("Plugin Initializing V5.2.0 (Stable)...");
84
+ log("Plugin Initializing V5.3.2 (Rollback)...");
109
85
  // START PROXY
110
86
  const port = await startProxy();
111
87
  const localBaseUrl = `http://127.0.0.1:${port}/v1`;
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.3.0",
4
+ "version": "5.3.2",
5
5
  "description": "Native Pollinations.ai Provider Plugin for OpenCode",
6
6
  "publisher": "pollinations",
7
7
  "repository": {