opencode-pollinations-plugin 5.3.1 → 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.
Files changed (2) hide show
  1. package/dist/index.js +20 -71
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -15,61 +15,19 @@ function log(msg) {
15
15
  catch (e) { }
16
16
  }
17
17
  const TRACKING_PORT = 10001;
18
- // === PORT MANAGEMENT (CROSS-PLATFORM) ===
19
- // We MUST kill the previous instance to ensure a fresh state.
20
- // Sticky ports = Zombies = Buggy Behavior.
21
- const freePort = (port) => {
22
- try {
23
- if (process.platform === 'win32') {
24
- // Windows: Find PID -> TaskKing
25
- try {
26
- const output = execSync(`netstat -ano | findstr :${port}`).toString();
27
- const lines = output.trim().split('\n');
28
- for (const line of lines) {
29
- const parts = line.trim().split(/\s+/);
30
- const pid = parts[parts.length - 1];
31
- if (pid && /^\d+$/.test(pid) && pid !== '0') {
32
- try {
33
- execSync(`taskkill /PID ${pid} /F`);
34
- log(`[Init] Killed Windows PID ${pid} on port ${port}`);
35
- }
36
- catch (e) { }
37
- }
38
- }
39
- }
40
- catch (e) { }
41
- }
42
- else {
43
- // Linux / macOS: lsof or fuser
44
- try {
45
- // Try lsof first (Cleaner)
46
- const pid = execSync(`lsof -t -i:${port}`).toString().trim();
47
- if (pid) {
48
- execSync(`kill -9 ${pid}`);
49
- log(`[Init] Killed PID ${pid} via lsof`);
50
- }
51
- }
52
- catch (e) {
53
- // Fallback to fuser (Linux specific but very effective)
54
- if (process.platform === 'linux') {
55
- try {
56
- execSync(`fuser -k ${port}/tcp`);
57
- log(`[Init] Cleaned port ${port} via fuser`);
58
- }
59
- catch (e2) { }
60
- }
61
- }
62
- }
63
- }
64
- catch (e) {
65
- // Ignored: Port likely already free
66
- }
67
- };
68
- // === 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
+ }
69
26
  const startProxy = () => {
70
- return new Promise(async (resolve) => {
27
+ return new Promise((resolve) => {
71
28
  const server = http.createServer(async (req, res) => {
72
- // ... (Request Handling - Unchanged) ...
29
+ // ... (Request Handling) ...
30
+ // We reuse the existing logic structure but simplified startup
73
31
  log(`[Proxy] Request: ${req.method} ${req.url}`);
74
32
  res.setHeader('Access-Control-Allow-Origin', '*');
75
33
  res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
@@ -84,7 +42,7 @@ const startProxy = () => {
84
42
  res.writeHead(200, { 'Content-Type': 'application/json' });
85
43
  res.end(JSON.stringify({
86
44
  status: "ok",
87
- version: "v5.3.0",
45
+ version: "v5.3.2",
88
46
  mode: config.mode
89
47
  }));
90
48
  return;
@@ -111,29 +69,20 @@ const startProxy = () => {
111
69
  res.writeHead(404);
112
70
  res.end("Not Found");
113
71
  });
114
- // Robust Startup Logic
115
- try {
116
- server.listen(TRACKING_PORT, '127.0.0.1', () => {
117
- log(`[Proxy] Started V5.3.1 on port ${TRACKING_PORT}`);
118
- resolve(TRACKING_PORT);
119
- });
120
- server.on('error', (e) => {
121
- log(`[Proxy] Fatal Bind Error: ${e}`);
122
- resolve(0);
123
- });
124
- }
125
- catch (e) {
72
+ server.listen(TRACKING_PORT, '127.0.0.1', () => {
73
+ log(`[Proxy] Started V5.3.2 (Legacy Port Logic) on port ${TRACKING_PORT}`);
74
+ resolve(TRACKING_PORT);
75
+ });
76
+ server.on('error', (e) => {
77
+ log(`[Proxy] Fatal Error: ${e}`);
126
78
  resolve(0);
127
- }
79
+ });
128
80
  });
129
81
  };
130
82
  // === PLUGIN EXPORT ===
131
83
  export const PollinationsPlugin = async (ctx) => {
132
- log("Plugin Initializing V5.2.0 (Stable)...");
84
+ log("Plugin Initializing V5.3.2 (Rollback)...");
133
85
  // START PROXY
134
- // 1. Force Clean Port
135
- freePort(TRACKING_PORT);
136
- // 2. Start
137
86
  const port = await startProxy();
138
87
  const localBaseUrl = `http://127.0.0.1:${port}/v1`;
139
88
  setGlobalClient(ctx.client);
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.1",
4
+ "version": "5.3.2",
5
5
  "description": "Native Pollinations.ai Provider Plugin for OpenCode",
6
6
  "publisher": "pollinations",
7
7
  "repository": {