opencode-pollinations-plugin 6.0.0-beta.18 → 6.0.0-beta.19
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 +32 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15,8 +15,16 @@ function log(msg) {
|
|
|
15
15
|
}
|
|
16
16
|
catch (e) { }
|
|
17
17
|
}
|
|
18
|
-
// === PROXY SERVER ===
|
|
18
|
+
// === PROXY SERVER (Singleton with Fixed Port) ===
|
|
19
|
+
const DEFAULT_PORT = 18888;
|
|
20
|
+
let existingServer = null;
|
|
21
|
+
let existingPort = 0;
|
|
19
22
|
const startProxy = () => {
|
|
23
|
+
// Singleton: reuse existing server if already running
|
|
24
|
+
if (existingServer && existingPort > 0) {
|
|
25
|
+
log(`[Proxy] Reusing existing server on port ${existingPort}`);
|
|
26
|
+
return Promise.resolve(existingPort);
|
|
27
|
+
}
|
|
20
28
|
return new Promise((resolve) => {
|
|
21
29
|
const server = http.createServer(async (req, res) => {
|
|
22
30
|
log(`[Proxy] Request: ${req.method} ${req.url}`);
|
|
@@ -60,16 +68,29 @@ const startProxy = () => {
|
|
|
60
68
|
res.writeHead(404);
|
|
61
69
|
res.end("Not Found");
|
|
62
70
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
// Try fixed port first, fallback to dynamic if occupied
|
|
72
|
+
const tryListen = (port, fallbackToDynamic) => {
|
|
73
|
+
server.listen(port, '127.0.0.1', () => {
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
const assignedPort = server.address().port;
|
|
76
|
+
existingServer = server;
|
|
77
|
+
existingPort = assignedPort;
|
|
78
|
+
log(`[Proxy] Started v${require('../package.json').version} on port ${assignedPort}${port === 0 ? ' (dynamic fallback)' : ''}`);
|
|
79
|
+
resolve(assignedPort);
|
|
80
|
+
});
|
|
81
|
+
server.on('error', (e) => {
|
|
82
|
+
if (e.code === 'EADDRINUSE' && fallbackToDynamic) {
|
|
83
|
+
log(`[Proxy] Port ${port} in use, falling back to dynamic port`);
|
|
84
|
+
server.removeAllListeners('error');
|
|
85
|
+
tryListen(0, false); // Try dynamic port
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
log(`[Proxy] Fatal Error: ${e}`);
|
|
89
|
+
resolve(0);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
tryListen(DEFAULT_PORT, true);
|
|
73
94
|
});
|
|
74
95
|
};
|
|
75
96
|
// === AUTH HOOK: Native /connect Integration ===
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-pollinations-plugin",
|
|
3
3
|
"displayName": "Pollinations AI (V5.6)",
|
|
4
|
-
"version": "6.0.0-beta.
|
|
4
|
+
"version": "6.0.0-beta.19",
|
|
5
5
|
"description": "Native Pollinations.ai Provider Plugin for OpenCode",
|
|
6
6
|
"publisher": "pollinations",
|
|
7
7
|
"repository": {
|