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 +0 -0
- package/dist/index.js +21 -45
- package/package.json +1 -1
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 /
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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(
|
|
27
|
+
return new Promise((resolve) => {
|
|
52
28
|
const server = http.createServer(async (req, res) => {
|
|
53
|
-
// ... (Request Handling
|
|
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.
|
|
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
|
-
|
|
96
|
-
|
|
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
|
-
|
|
101
|
-
log(`[Proxy] Fatal
|
|
102
|
-
resolve(0);
|
|
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
|
|
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